File not found in c# RRS feed

  • Question

  • string pathSource = @"E:\\FileSaving\\" + filename;

     byte[] ciphertext;



    using (FileStream fsSource = new FileStream(pathSource, FileMode.Open, FileAccess.Read))



    // Read the source file into a byte array.

                ciphertext = new byte[fsSource.Length];

    int numBytesToRead = (int)fsSource.Length;

    int numBytesRead = 0;


    while (numBytesToRead > 0)





    // Read may return anything from 0 to numBytesToRead.


    int n = fsSource.Read(ciphertext, numBytesRead, numBytesToRead);


    // Break when the end of the file is reached.


    if (n == 0)



                    numBytesRead += n;

                    numBytesToRead -= n;




    [FileNotFoundException: Could not find file 'E:\FileSaving\ temp.txt'.]
       System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +305
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +67
       Access.Button1_Click(Object sender, EventArgs e) in e:\mona\Access.aspx.cs:71
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    Wednesday, March 5, 2014 7:53 AM


  • Open that folder and provide access rights to that folder

    right click the folder name

    in that click properties

    from that choose security

    in that provide access rights to system users.

    • Marked as answer by Rajendran123 Saturday, March 22, 2014 7:47 AM
    Saturday, March 22, 2014 7:47 AM