File Not Found Exception while accessing file from UNC Path RRS feed

  • Question

  • Hi,

    I have a requirement to access the file present in UNC path.

    While accessing the file, application throws file not exception and file size is shown as 0 KB.

    The same file shows size > 0 KB when copied and pasted in windows explorer.

    Is this the limitation or by design from Framework side?

    Thanks in advance,

    Vijay Zalaki 

    Wednesday, December 19, 2018 12:18 PM

All replies

  • Hello,

    Please post your code, environment, Framework version, and also indicate yes or no you have authority to th folder in question

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, December 19, 2018 2:12 PM
  • Hi Vijay Zalaki,

    Thank you for posting here.

    For your question, you want to know why it will have the exception.

    If the file does not exist in the UNC path, it will generate an exception.

    Here is my test code.

    string FileName= @"\\xxx\test1\test2.txt";
                FileStream stream = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                StreamReader reader = new StreamReader(stream);


    Best regards,

    Jack J Jun.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 21, 2018 8:04 AM