locked
Access Local file through network share fail? RRS feed

  • Question

  • When i use FileStream to read data from local files in network share format(in same machine), i find FileStream.Read() will fail because error 1450. Sample code list below:
    string path=@"CurrentPCIPAddress\sharePath\fileName";
    FileStream stream =new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
    byte[] buf = new byte[stream.Length];
    stream.Read(buf, 0, (int)stream.Length);
     return buf;
    If the file is large enough ,in my case about 200M ,the sample code will fail , but if the file is on another pc , it will be success. My pc is windowsXP+sp2 . I find if i set FileShare.Read to FileShare.None, it will be success.
    Why?



    Wednesday, June 6, 2007 7:17 AM

Answers

  • Error 1450 is "Insufficient system resources".  That seems pretty disconnected from the file sharing mode.  Unless there's some bizarre Windows file system driver bug that would leak handles.  You are doing something pretty unusual of course.  Use Process Explorer and look at the Performance tab in the properties window to see what kind of resource is being consumed.
    Thursday, June 7, 2007 2:45 PM