Creating file in shared folder

I need to access a folder on a network ( say \\server1\test ). test folder is shared on \\server1 with permission only to user 'A'. Now a java program ( Simple code snippet given below ) running will not be able to access the given folder due to access restriction. How can I make this code access the given folder and create a file xyz.txt in it.
Code snippet :
import java.io.File;
import java.io.IOException;
public class test
public static void main(String[] args)
File file = new File(\\\\server1\\test\\xyz.txt );
try
file.createNewFile();
catch (IOException e)
// TODO Auto-generated catch block
e.printStackTrace();
}

make sure that you have read and write permissions on that shared resource. i mean full access on that shared folder. with out full access you can't create/delete anything there. with read only access, you can read the content of the folder as well as that file only.
Diablo

Similar Messages

  • How to store files in shared-folder in background mode

    Hello All,
    My requirement seems to be simple but I have tried many ways in achieving this, but failed. So require the help in accomplishing this task.
    Requirement
    I have to create a program in SE38 which will create a internal table with data in it in .XML format(which I can achieve).
    My requirement is this .XML file needs to be placed in a shared-folder in "BACKGROUND MODE".
    I have tried using GUI_DOWNLOAD function module, but this FM only runs in Foreground mode and fails in Background mode. I have tried convincing my client that I will keep the file in Application Server as it is achievable using OPEN DATASET statements, but they are not willing to accept this.
    So can you please help me in achieving this task as I am not getting any solution how to keep the file in Shared-folder in BACKGROUND mode itself(not Foreground).
    Best Regards,
    Tousif

    Hi Sanjeev,
    I have just used normal GUI_DOWNLOAD FM. Please find my sample code below
    CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
    *       BIN_FILESIZE                    =
           filename                        = 'D:\Users\baigtomx\Desktop\TOUSIF.XML'
    *       FILETYPE                        = 'ASC'
    *       APPEND                          = ' '
    *       WRITE_FIELD_SEPARATOR           = ' '
    *       HEADER                          = '00'
    *       TRUNC_TRAILING_BLANKS           = ' '
    *       WRITE_LF                        = 'X'
    *       COL_SELECT                      = ' '
    *       COL_SELECT_MASK                 = ' '
    *       DAT_MODE                        = ' '
    *       CONFIRM_OVERWRITE               = ' '
    *       NO_AUTH_CHECK                   = ' '
    *       CODEPAGE                        = ' '
    *       IGNORE_CERR                     = ABAP_TRUE
    *       REPLACEMENT                     = '#'
    *       WRITE_BOM                       = ' '
    *       TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *       WK1_N_FORMAT                    = ' '
    *       WK1_N_SIZE                      = ' '
    *       WK1_T_FORMAT                    = ' '
    *       WK1_T_SIZE                      = ' '
    *       WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    *       SHOW_TRANSFER_STATUS            = ABAP_TRUE
    *       VIRUS_SCAN_PROFILE              = '/SCET/GUI_DOWNLOAD'
    *     IMPORTING
    *       FILELENGTH                      =
         TABLES
           data_tab                        = lt_wo
    *       FIELDNAMES                      =
    *     EXCEPTIONS
    *       FILE_WRITE_ERROR                = 1
    *       NO_BATCH                        = 2
    *       GUI_REFUSE_FILETRANSFER         = 3
    *       INVALID_TYPE                    = 4
    *       NO_AUTHORITY                    = 5
    *       UNKNOWN_ERROR                   = 6
    *       HEADER_NOT_ALLOWED              = 7
    *       SEPARATOR_NOT_ALLOWED           = 8
    *       FILESIZE_NOT_ALLOWED            = 9
    *       HEADER_TOO_LONG                 = 10
    *       DP_ERROR_CREATE                 = 11
    *       DP_ERROR_SEND                   = 12
    *       DP_ERROR_WRITE                  = 13
    *       UNKNOWN_DP_ERROR                = 14
    *       ACCESS_DENIED                   = 15
    *       DP_OUT_OF_MEMORY                = 16
    *       DISK_FULL                       = 17
    *       DP_TIMEOUT                      = 18
    *       FILE_NOT_FOUND                  = 19
    *       DATAPROVIDER_EXCEPTION          = 20
    *       CONTROL_FLUSH_ERROR             = 21
    *       OTHERS                          = 22
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.
    When I run this program in foreground mode, the file gets saved(here in the above example I have just used my desktop path. but the actual requirement is to store file in shared-folder i-e Network Drive).
    But when i run the same program in background mode, No file is getting stored.
    Regards,

  • Windows 2008 : How to Restrict Users to Copy file from Shared Folder

    Hello All,
    I need to Restrict Users to Copy file from Shared Folder. Please let me know is there any method to achieve this requirement.

    If user have Read permission, they can copy it. So actually you cannot restrict user from copy your files if they could read/edit.
    Some programs could help restrict users from edit/modify/copy the content of their files such as Office files, PDF files etc as Oscar said above.
    TechNet Subscriber Support in forum |If you have any feedback on our support, please contact [email protected]

  • How to create file in specific folder...

    Hi developers,
    I am new to java. I would like to create file in some folder. But i am fail to create it. Can any body help me please..
    This is my code. It creates folder well...But file doesn't create.
    import java.io.*;
    public class file1
         public static void main(String ar[])
              File f = new File("c:\\ram");
              f.mkdirs();
              String pat = f.getAbsolutePath();
              File ffs = new File("c:\\ram.txt");
              System.out.println(pat);
    }With Regards
    sure...:)-

    Also, it's not clear where you want the file.
    You're making a directory C :\ram, but then you're talking about a file ram.txt that's right in C:
    Also, you can use / instead of doubling up the \ and it wil get converted properly.
    If I wanted to create a file C:\ram\ram.txt I'd do this:
    File parentDir = new File("C:/ram");
    File file = new File(parentDir, "ram.txt");
    parentDir.mkdirs();
    file.createNewFile();

  • Some junk files created in my shared folder

    hi
    i have a server 2012 r2 and I shared a folder for network access.
    my clients are xp and seven.
    after 1 week some junk files apeared in my folder.
    I deleted them but another files apear after some days.
    files name like :
    2fv34
    df542

    Hi Reza,
    Sorry for my delay.
    Based on your description, I understand that some odd files are created automatically in the shared folder.
    If anything I misunderstand, please don’t hesitate to let me know.
    Please run anti-virus software to scan the Windows Server 2012 R2 firstly.
    Please let me know the type of those odd files. Or provide a screenshot of this file (please hide all protected
    and private information). Meanwhile, please right click that file and select Properties. Navigate to General tab, Security tab and check if find some exceptions.
    In addition, please open Control Panel on the server, select Folder Options, select View tab. There will be
    two options under Hidden files and folders: Don’t show hidden files, folders, or drives and
    Show hidden files, folders and drives. Please check if there has differences in those odd files when you check each option.
    If any update, please feel free to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • How do i Secure & recover file from shared folder

    Hi All,
    I have Windows server 2008 R2 environment and one shared folder created on this with restricted permission by file sharing & security, now 1. I want to add one more restriction that owner of the folder should not able to delete that file? If this is
    not available with Microsoft then
    2. How do i recover file which deleted from MAP drive...
    Please help me to resolve this issue...
    Kalpesh Chauhan

    As to your first problem, I am not so familiar. But, as to the second problem, I think I can help.
    In fact, I have ever also accidentally deleted my hard drive files. In order to re-access them, I have also posted my question in forums, just like you. Fortunately, after browsing many related answers and threads, I just know that a third
    party data recovery program can be a good chance to go on.
    So, I follow some instructions in these forums and select three drive recovery freeware to go on, including Recuva, iCare Data Recovery Free and TestDisk and so on.
    Finally, I have restored all my needed data back successfully with these freeware.
    So, I hope it will also help you out.
    PS: Never forget to back up everything important on different hard drives or places in case of any similar data recovery problems in the future.

  • Archiving File on Shared Folder in Linux using java code

    Hi All,
    I have a requirement wherein I have to ftp a file (Feed.txt) from windows FTP server to Linux machine1 and archive the same file (with timestamp suffixed on file name like Feed.txt_22April) on Linux Machine2. I am
    trying to achieve this through java code. I am able to ftp the file(Feed.txt) from windows ftp server to Linux machine1 /opt/ftproot directory and archiving the same file under /opt/ftproot/archive directory of Linux
    Machine1 with timestamp suffixed on file name.
    My archiving requirement is still not achieved. So, for that I created a shared folder “/temp/shared” on Linux Machine2 and mounted the /temp/shared folder of Linux Machine2 on /opt/ftproot/archive folder of
    Linux Machine1 using following command:
    # mount LinuxMachine2: /temp/shared /opt/ftproot/archive
    Note: I have given full permission on both the folders.
    Logically, archiving the Feed.txt with timestamp in it name under /opt/ftproot/archive folder should create the file in /temp/shared folder of Linux Machine2. But instead of archiving the file on
    /opt/ftproot/archive folder, it archive the file on /opt/ftproot folder.
    In my java code, I have specified copyDir as “/opt/ftproot” and archiveDir as /opt/ftproot/archive”.
    The code is being run from Linux Machine1 as a schedule task.
    Please help.
    PFB the code snippet:
    package com.ftp;
    import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;
    import org.apache.commons.net.ftp.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    public class FTPService extends SchedulerBaseTask {
         private static String targetDir="";
         private static String archiveDir="";
    public void init() {
    public void execute() {
    try {
    String server = "Machine1
    String username = "username";
    String password = "password";
    String sourceDir = "C:\\Inetpub\\ftproot\\temp.txt";
    //String archiveDir = "/home/ftproot1";
    targetDir = getAttribute("Target Directory");
    FTPClient ftp = new FTPClient();
    * Connect to the server
    ftp.connect(server);
    ftp.login(username, password);
    System.out.println("Connected to " + server + ".");
    String[] names = ftp.listNames();
    for (String name : names) {
    System.out.println("Name = " + name);
    * Get all file names that are present in the current working directory
    FTPFile[] files = ftp.listFiles();
    String fileName = "";
    for (int i = 0; i < files.length; i++) {
    if (files.isFile()) {
    System.out.println("\t" + files[i].getName());
    File file = new File(targetDir + File.separator +
    files[i].getName());
    FileOutputStream fos = new FileOutputStream(file);
    * Copy the file to target system
    ftp.retrieveFile(files[i].getName(), fos);
    fos.close();
    fileName = files[i].getName();
    ftp.logout();
    ftp.disconnect();
    System.out.println("End of FTP....");
    System.out.println("Calling fileCopy()");
    System.out.println("Target Directory"+targetDir);
    fileCopy(fileName,targetDir);
    } catch (Exception e) {
    e.printStackTrace();
    public static String getDate() {
    String sdate = "";
    try {
         System.out.println("Inside getDate()");
    Calendar date = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat(
    "yyyy-MM-dd HH:mm:ss.0");
    sdate = formatter.format(date.getTime());
    } catch (Exception e) {
    return sdate;
    public void moveFile(String t) {
         try{
         System.out.println("inside moveFile");
    System.out.println("Moving Files");
    File fro = new File(t);
    archiveDir = getAttribute("Archive Directory");
    System.out.println("Archiving Directory"+archiveDir);
    File to = new File(archiveDir);
    boolean archived = fro.renameTo(new File(to, fro.getName()));
    if (archived) {
    System.out.println("FileArchived");
              /*String cmd="mv" +" "+t +" "+ "/home/ftproot/archive";
              System.out.println("Archive Directory"+archiveDir);
              System.out.println("Move Command"+cmd);
              Process SshProc =      (Runtime.getRuntime()).exec(cmd);
    } catch (Exception e) {
    e.printStackTrace();
    public void fileCopy(String filename,String Directory) {
         try{
         //String ifile="/home/ftproot/sunny.txt";
              String ifile=targetDir+"/"+filename;
         String ofile=ifile+"_"+getDate();
         File f1 = new File(ifile);
         File f2 = new File(ofile);
         InputStream in = new FileInputStream(f1);
         //For Append the file.
    //      OutputStream out = new FileOutputStream(f2,true);
         //For Overwrite the file.
         OutputStream out = new FileOutputStream(f2);
         byte[] buf = new byte[1024];
         int len;
         while ((len = in.read(buf)) > 0){
         out.write(buf, 0, len);
         in.close();
         out.close();
         System.out.println("File copied.");
         moveFile(ofile);
         }catch(Exception e)
         System.out.println("File copied."+e);
    Cheers,
    Sunny

    sunnyajmera wrote:
    Please help.If it was me....
    - You are connecting to a ftp server. I am guessing you didn't write that.
    - Get a flexible ftp client, there are many but make sure it shows you the ftp result codes.
    - Figure out how and if the ftp server will do what you want.
    If it does do what you want then ftp client will let you do the same thing.
    If that ftp server doesn't allow you to do it then you must do one of the following
    - Find a different server
    - Change the requirements
    - Find a way to impose the requirements using a tool in addition to ftp like some command executed through telnet.

  • Cannot delete file from shared folder

    While I was looking for another file in my shared folder, I discovered a jpg file named shannonhenry.jpg. All it appears to be is a school photo of a boy, maybe 14 or so. I tried to move it to trash to delete it because I do not know who this kid is, and I got an error message saying that I do not have sufficient priviledges. Anyone know what this file is or could be????

    Well Kelley, that photo did not come with the system so it had to come from you or someone else putting in the Shared folder.
    Choose the file and "get info" (command- i) turn the dislclosure triangle on "Ownership & Permissions" make sure you can "read & write" and make yourself the "owner"(open the lock and enter your admin password).
    Then check under General, turn the disclosure triangle and be sure the "locked" box in NOT checked.
    Let us know.
    -mj
    [email protected]

  • How to read .mdb file from shared folder

    Hi All,
    In one of my local computer I have a shared folder and within the folder I have a .mdb file. Now I am trying to read that file from MII. I have tried with Get_File_List action block. I am providing the following information to Get_File_List
    Folder :
    <Computer Name>\<Shared Folder Name>
    Mask: .mdb
    But in return of Get_File_List, I am not getting any file related information. It is only providing like below
    <Rowsets>
    <Rowset>
    <Columns>
    <Column Description="Name" MaxRange="0" MinRange="0" Name="Name" SQLDataType="1" SourceColumn="Name"/>
    <Column Description="Date" MaxRange="0" MinRange="0" Name="Date" SQLDataType="93" SourceColumn="Date"/>
    <Column Description="Size" MaxRange="100" MinRange="0" Name="Size" SQLDataType="4" SourceColumn="Size"/>
    <Column Description="LastWriteDate" MaxRange="0" MinRange="0" Name="LastWriteDate" SQLDataType="93" SourceColumn="LastWriteDate"/>
    <Column Description="ReadOnly" MaxRange="1" MinRange="0" Name="ReadOnly" SQLDataType="4" SourceColumn="ReadOnly"/>
    <Column Description="FullPath" MaxRange="0" MinRange="0" Name="FullPath" SQLDataType="1" SourceColumn="FullPath"/>
    </Columns>
    </Rowset>
    </Rowsets>
    Can anybody suggest me how to achieve it.
    Thanks in advance
    Chandan

    Hi Chandan,
    Specify the mask as *.mdb and try.
    Thanks,
    Dipankar

  • Read file from shared folder

    Hi,
    I want to read a file "test.txt" from the server "XY" (my own PC) with the shared folder "devices$"
    I want to check first whether the file exists:
    FileInfo myFile = new FileInfo(@"\\XY\devices$\test.txt");
    if (myFile.Exists)
    Console.WriteLine("exists");
    else
    Console.WriteLine("does not exist");
    The result is always "does not exist" even though the file exists, why??

    I tested your code, It works fine on my side. So i doubt whether the file
    exists.  Please check your file. Or do you have right to access the file?
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Not allowed to move (only copy) files within Shared Folder (yes, permissions are set to Read/Write)

    I have moved my media (Music, Movies, Pictures) to the Users/Shared folder.  As I'm doing some cleanup in these folders, I am trying to move several folders/files at once, all within the same Shared folder.  I have confirmed that the permissions settings under "Get Info" are set to "Read/Write" and I have verified and repaired permissions with Disk Utility.  However, every move I try to do is a copy.  I have tried the Command-Drag method, but I'm still left with the green plus sign indicating a copy.
    On smaller files/folders, this wouldn't matter so much as I would copy, then just delete the original.  But I'm dealing with many, many gigs of music and my HD doesn't have space for holding copies, even if the originals will be deleted.
    Very frustrating to have to spend so much time to figure out what would seem to be a very basic file management feature.
    I've searched and read and searched some more, but I'm stuck.  Thanks to any who can help. 

    Do have file sharing and remote login checked
    When on Betty's computer, Sign into Bob's computer with Bob's username & Bob's Password, instead of Betty's.
    BINGO!!!!  Problem solved.  Many thanks!!!

  • Creating file in a folder

    There doesn't seem to be any way to right-click and create a text/ open office file in a folder. At the moment, I am launching the application (e.g. Text edit), saving my document in the desktop and then drag and drop the document to the specific folder.
    Is there any easier way?
    Thanks.

    Open the AppleScript Editor in the /Applications/Utilities/ folder and paste in the following:
    tell application "Finder"
    make file in (get folder of window 1)
    end tell
    Save it as an application and put it in the Dock or the Finder's toolbar. This will only work with TextEdit as written, but if you have a blank document in any format presaved elsewhere, it can be copied there.
    (109971)

  • How to Create File in another folder

    hi,
    I need to create a RandomAccessFile in Folder and that Folder was also created here if self only, so How it do this in a program.
    tname="xyz";
    String fname=tname+".xml";
    file = new File(fname);
    File dir=new File(tname);
    String path=dir.getAbsolutePath();
    System.out.println(path);
    if(dir.exists()==false)
    dir.mkdirs();
    I try to create xyz.xml file in xyz(folder name) itself, how can if be
    Thanking you,
    RaviVarma.K

    I'm not sure what you are trying to do but you seem to need
            File f = new File("the path of the file you want to create");
            f.getParentFile().mkdirs();No need to make the mkdirs() conditional since it will only make the directories if they don't exist.

  • Creating documents in shared folder of SAP mail

    Hi all,
    I would like to create documents in a shared folder of my sap mail. I know it can be done by method create of object SOFM. I just don't know how to set up this method. What parameters are needed and how to do it correctly.
    Thx for helping,
    Yoolb

    Hi Yoolb,
    Are you trynig to do this within a Workflow? If your need is to create the document from a custom program, you can use the function module SO_DOCUMENT_INSERT_API1.
    Cheers,
    Ramki Maley.
    Please reward points if the answer is helpful.
    For info on awarding points click on this link: https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm

  • Slow access to DBF files on shared folder in Win7 Prof

    Hi,
    I've a LAN based on 5 XP workstations and one Win7x64 computer with shared folder. No firewall, no antivirus software on this machine. There are some DBF-files in this folder. DOS application is running on these 5 workstations. This application uses shared
    DBF-files. When I useed share folder based on XP-machine application worked normaly, access to these files was well rounded. After changing the "server" the access is never ending. Browsing/reading/writing data is a horror.
    Have you any ideas?
    Regards.

    Hi,
    Could you please tell more details regarding this sentence” After changing the "server"
    the access is never ending. Browsing/reading/writing data is a horror.”
    How does the DOS application work here?
    When we configured the application to access the DBF files on Windows 7, have we received any
    special errors?
    As the application worked well on the Windows XP workstation, might we consider to use process
    monitor to compare with the same process on Windows 7?
    Troubleshooting
    with Process Monitor
    Best regards
    Michael Shao
    TechNet Community Support

Maybe you are looking for

  • Remote app on Ipad 2 (and Apple TV 1st gen)

    Hi, I have an Apple TV (1st gen) which I control thorugh an Iphone 4 and Ipad 1. I recently bought an Ipad 2 and installed the Remote app. The app finds my ATV and I can control the music in it, but the control function (that allow the ipad screen to

  • Cannot drop login from SQL 2012

    I am trying to drop a login with no mapped dbs, no owned schemas, no rights, no endpoints, nothing what-so-ever and I have been at this for 4 hours.  This is the error, is there any global way to determine what in the world SQL 2012 sees this login a

  • Manufacturing-admin still not working

    Hi everyone! I had no problem in getting SQL Trace up and running on my local Netweaver instance. However now I'm stuck getting SQL Trace running on our test machine. I followed the instructions given in the respective documents as well as the ones g

  • Dynamic Actions with Multiple Actions Capability

    Dynamic Actions with Multiple Actions Capability How can I get Dynamic Actions to work on Actions that are stored solely on IT0302 due to the multiple relationship to a previous Action that is stored on both IT0302 and IT0000? When multiple actions o

  • Forms configuration file in Unix

    Hi We're using Forms 9i. Is there any configuration file in Unix in wich I can set Forms to read .pll files instead of .plx? TIA, Marcos