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.

Similar Messages

  • 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]

  • Reading files from shared mapped folders

    How is the correct approach to read files from a volume which maps a shared disk?
    I mean, we have the Y:\Folder which maps \\bla_bla\root\folder.
    Our application has to read into Y:\Folder.
    How do we create a File object which points to Y:\Folder?
    Thanks.

    > We catch a java.lang.NullPointerException
    Okay. You know how to debug those, right? Some condition exists that is causing an NPE (that line alone won't do it), so you'll need to do some investigating.
    How to resolve a java.lang.NullPointerException
    You'll want to ensure that the directory actually exists, you've mapped it correctly, you have the appropriate permissions to access it, etc.
    Good luck!
    ~

  • Can't copy file from Shared Folder

    Hi,
    Does anyone here knows how to copy file from shared music. I can view others shared music but can't do anything about it. When I tried to Right Click on music I want to copy. There are only 3 options (Get info, Unchecked Selection & Copy). I chose copy, but don't know what to do next. I wanted to place it in my Library but don't have an option to do it.
    Please help.
    Thanks,
    guadz

    I've never copied music, but have you tried just dragging the file to your library? Not 100% sure if it works, never tried it myself. Also, if you right click in your library, can you paste?

  • Reading file from a folder : File dir = new File(URL+aFile_to_add);

    Hi,
    Trying to read files from a dir on my site using a JSP and bean. I've tried nearly every option for the filepath I can think of and it doesn't seem to be finding the file...
    Here's the bit:
    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    It's working locally, but I obviously had to change the path from c://... to the above.
    The full code is listed below in the addWedding Method
    The method removes the .jpg from the file name and then writes the new file name to a database
    Thanks for any insight.
    Regards
    Jim
    public String addWedding(String aFile_to_add)
    String feedback = "unset in scrubWedding";
    try
    String URL = "images\\wedding_photos\\";
    Class.forName("org.gjt.mm.mysql.Driver");
    java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/rhwedd2_shop?user=**********&password=*******");
    java.sql.Statement statement = connection.createStatement();
    File dir = new File(URL+aFile_to_add);
    String[] files = dir.list();
    if (files == null)
    feedback = "Sorry, couldn't find the file "+aFile_to_add+"...no files have been added.";
    else
    for (int i=0; i<files.length; i++)
    // Get filename of file or directory
    String filename = files;
    String no_extension;
    //convert string array element into a char array
    char [] charsfilename = filename.toCharArray();
    int newlength = charsfilename.length -4;
    no_extension = String.valueOf(charsfilename,0,newlength);
    filesAdded = filesAdded+", "+no_extension;
    // Show the new file names in stack trace without extension
    //System.out.println("String no_extension " + no_extension );
    statement.executeUpdate("INSERT INTO items VALUES ('"+no_extension+"',5,'"+aFile_to_add+"')");
    // write to table with item_id and weddingid
    feedback = "The following files have been added..."+filesAdded;
    if (statement != null )
    statement.close();
    if ( connection != null )
    connection.close();
    catch(Exception e)
    feedback = "Into the catch";
    e.printStackTrace(System.err) ;
    return feedback;
    }//end addWedding

    String URL = "images\\wedding_photos\\";
    File dir = new File(URL+aFile_to_add); ok, ok, I'll answer...
    1) What gives you the impression that the relative directory "images\\..." exists (or, in other words, what makes you think your current directory is the parent of "images"?

  • 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

  • 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 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.

  • Reading files from shared lib in WAS 5.1

    I have a shared library name 'files' in WAS 5.1. The classpath is ${TEST_FILES}/shared.
    I have some textfiles in that directory, not properties files. Can I read those file from that directory from Session Bean like
    File f = new File("${TEST_FILES}/shared/some_file.txt");
    Can't have that done. What is the right way to do it? Or is there any?

    Enterprise beans aren�t allowed to access files primarily because files are not transactional resources. Allowing EJBs to access files or directories in the file system, or to use file descriptors, would compromise component distributability, and would be a security hazard.
    Another reason is deployability. The EJB container can choose to place an enterprise bean in any JVM, on any machine in a cluster. Yet the contents of a file system are not part of a deployment, and are therefore outside of the EJB container�s control. File systems, directories, files, and especially file descriptors tend to be machine-local resources. If an enterprise bean running in a JVM on a particular machine is using or holding an open file descriptor to a file in the file system, that enterprise bean cannot easily be moved from one JVM or machine to another, without losing its reference to the file.
    Furthermore, giving EJBs access to the file system is a security hazard, since the enterprise bean could potentially read and broadcast the contents of sensitive files, or even upload and overwrite the JVM runtime binary for malicious purposes.
    Having said all this, my understanding is that the EJB file restriction can be broken if the developer really, really knows what they are doing and accepts the consequences such as those above. I did this on a recent WebSphere project and accessed files in a named directory on the application server box using the standard file IO APIs. It just meant that if the application was deployed to another server, the same directory structure would need to be recreated.
    If you're working with read-only data a more appropriate way would be to store the files in a deployment JAR, and access then with the getResource() or getResourceAsStream() methods of java.lang.Class.

  • Reading file from an external folder.

    Iam tring to read an external file from the C:\ drive. Given below is the code.
    DATA LV_XLS(100) TYPE C.
    DATA LV_CONTENT TYPE XSTRING.
    LV_XLS = 'C:\XML\Report.xls'
    READ DATASET LV_XLS INTO LV_CONTENT.
    But when i execute iam getting an error - FILE NOT FOUND. How do i read file from an external folder. My requirement is to strictly read from an external folder. Please help.
    If this is not possible please advice as to how the file could be moved to the SAP root directory. Iam not able to locate the root.

    hi,
    This is the code to read a excel file from the local system.
    Read data set you are using in your code corresponds to files on application server thats the reason its throwing an error.
    * Parameter variable declaration for browsing the file location       *
    PARAMETERS:
      p_file TYPE ibipparms-path OBLIGATORY.
    data:
    it_text TYPE truxs_t_text_data .
    AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         program_name        = syst-cprog
    *   DYNPRO_NUMBER       = SYST-DYNNR
         field_name          = ' '
       IMPORTING
         file_name           = p_file.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    *   I_FIELD_SEPERATOR          =
    *   I_LINE_HEADER              =
          i_tab_raw_data             = it_text
          i_filename                 = p_file
        TABLES
          i_tab_converted_data       = t_cust
      EXCEPTIONS
        conversion_failed          = 1
        OTHERS                     = 2
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    This is to read a text file from local system.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
        filename                      =  'D:\FILEINTERFACE\file.TXT'
    *    FILETYPE                      = 'ASC'
         has_field_separator           = 'X'
    *    HEADER_LENGTH                 = 0
    *    READ_BY_LINE                  = 'X'
    *    DAT_MODE                      = ' '
    *    CODEPAGE                      = ' '
    *    IGNORE_CERR                   = ABAP_TRUE
    *    REPLACEMENT                   = '#'
    *  IMPORTING
    *    FILELENGTH                    =
    *    HEADER                        =
        TABLES
          data_tab                      = t_kna1
    *  EXCEPTIONS
    *    FILE_OPEN_ERROR               = 1
    *    FILE_READ_ERROR               = 2
    *    NO_BATCH                      = 3
    *    GUI_REFUSE_FILETRANSFER       = 4
    *    INVALID_TYPE                  = 5
    *    NO_AUTHORITY                  = 6
    *    UNKNOWN_ERROR                 = 7
    *    BAD_DATA_FORMAT               = 8
    *    HEADER_NOT_ALLOWED            = 9
    *    SEPARATOR_NOT_ALLOWED         = 10
    *    HEADER_TOO_LONG               = 11
    *    UNKNOWN_DP_ERROR              = 12
    *    ACCESS_DENIED                 = 13
    *    DP_OUT_OF_MEMORY              = 14
    *    DISK_FULL                     = 15
    *    DP_TIMEOUT                    = 16
    *    OTHERS                        = 17
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    PS.  In both of the above mentioned function modules make sure that the file structure is similar to the internal tables used.
    Thanks
    Sharath

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • Reading a file from a folder.

    Hi everyone,
    I am trying to modify my first java program.
    The method below is used to read a file that is hard coded in the below method. What I would like it to do is to pick up files that are stored in a folder. The reason for this is that the file names will never be the same.
    I am unsure how to do this and would appreciate some help from you.
    Thanks in advance.
    public void fileBreakdown()
              try
                   FileReader file = new FileReader("files/myTextFile.txt");
                   BufferedReader buffer = new BufferedReader(file);
                   String textline = null;
                   ArrayList arr =  new ArrayList();
                   while ((textline = buffer.readLine()) != null)
                        boolean syswarnEndFound = false;
                        if((textline.substring(45, 52)).equals("SYSWARN"))
                             System.out.println(textline.substring(45, 52));
                             arr.add(textline);
                             while ((textline = buffer.readLine()) != null && !syswarnEndFound)
                                  if(textline.indexOf("}") == -1)
                                       //System.out.println("not found : " + textline);
                                       buffer.mark(1000);
                                       arr.add(textline);
                                  else
                                       //System.out.println("found");
                                       syswarnEndFound = true;
                                       buffer.reset();
                                       OutputFileTypes.processSYSWARN(arr);
                        else if((textline.substring(45, 51)).equals("SYSMSG"))
                             System.out.println("Stopped, program ends");
                             System.out.println(textline.substring(45, 51));
                             arr.add(textline);
                             while ((textline = buffer.readLine()) != null && !syswarnEndFound)
                                  if(textline.indexOf("}") == -1)
                                       buffer.mark(1000);
                                       arr.add(textline);
                                  else
                                       syswarnEndFound = true;
                                       buffer.reset();
                                       OutputFileTypes.processSYSMSG(arr);
                        else
                             String[] messageArr = textline.split(" ");
                             Processing.whichFileType(getSubject(messageArr),getMessage(messageArr),getPublishedDate(messageArr));
                             getPublishedDate(messageArr);
                   buffer.close();
              catch( IOException e) {System.out.println(e);}
         }

    I could not compile your code. But if you wanted to get all .txt files from a folder then you could do something like this
    class EndsWith implements FilenameFilter {
         String ext;
         public EndsWith(String ext) {
              this.ext = "." + ext;
         public boolean accept(File dir, String name) {
              return name.endsWith(ext);
         public static void main(String args[]) {
              String srcDir="C:/temp/";
              try {
                   File srcFiles = new File(srcDir);
                  FilenameFilter filteredFiles = new EndsWith("txt");
                  String sourceDir[]=srcFiles.list(filteredFiles);
                  for(int i=0;i<sourceDir.length;i++)
                       String fileName = srcDir+sourceDir;
              System.out.println(fileName);
              FileReader file = new FileReader(fileName);
              //..your code here
              }catch(IOException ioe) {
                   ioe.printStackTrace();
    NOTE: I haven't tested this code. You can give a try.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • File copy from SHARED folder to Application server

    Hi
    I have a file which is in a shared folder. My requirement is to copy this file into the application server.
    The function module C13Z_FILE_UPLOAD_BINARY is working fine with local files. But I could not use it to copy the file in shared folder.
    Please help me out.
    Points will be awarded for sure !!
    Thanks

    hi,
    use OPEN DATASET ... TRANSFER ... CLOSE DATASET to transfter the data on to the required file path ... else use transaction
    CG3Z - to upload file from presentation server to application server.
    Regards,
    Santosh

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • Error While reading an Excel file from KM Folder.

    Hi Guru's,
    In my PDK Application I am trying to read an Excel file from KM Folder.
    Workbook workbook = Workbook.getWorkbook(new File("/irj/go/km/docs/documents/test/Test.xls"));
    It gives an error:
    Error:java.io.FileNotFoundException: \irj\go\km\docs\documents\test\Test.xls (The system cannot find the path specified)
    Details of appli:
    In my JspDynpage I am calling a utility Java file.
    There I have to read an  Excel and to passit to JSP.
    Details of jar files  used:
      jxl-2.6
      com.sap.security.api.jar
    Regards,
    Ram

    Hi,
    You are trying to read file wrong way. In the tutorial of Java Excel Api: "JExcelApi can read an Excel spreadsheet from a file stored on the local filesystem or from some input stream.". You are trying to read from file system. So you must get file input stream then you can read it. Please search forums KM file read.

Maybe you are looking for

  • Multi-Monitor PSE 9 Corrupt Display

    Multi-Monitor PSE 9 Corrupt Display Evening all - First post here at PS Gurus.  I hope that you guys can lend your  expertise in pinning down an issue that I am having and have also had on  other PS versions.  I am running Windows 7 (64 bit) Ultimate

  • No. of records in the table

    Is any system table or a program that gives us the # of records by SAP metadata table name ?.. i have a list of table names & need to know the # of recs in all of them...so can try looking at the larger ones for analysis.. ?

  • Bookmarks in safari on I pad

    I now have thousands  of  bookmarks in safari. Could someone tell me how to delete them. I deleted the on the computer but can't delete themon the I pad. If I turn on safari on iCloud it puts them back on the computer . It's impossible to delete the

  • WD Abap and WD Java in same portal page

    Hi to all, I need the following: I have a portal page with somes WD Java iviews, the first wd Java send a parameter to the others wd Java. I need add one iview in this page with a new WD Abap application and send the same parameter (from the wd java

  • Weblogic on freeBSD

    I've installed Weblogic 6.1 on unsupported system (FreeBSD 5.2.1) and it works quite fine. But I'd like to insall 8.11. I've tried to install linux version in linux compability mode, but built-in jre causes an error. There are few messages about pj_s