none
uploading the file into ftp server RRS feed

  • Question

  • hi ,

    when i am trying to upload the files into my ftp server it was displaying the following error. can any one help me to solve this error

    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.FileNotFoundException: Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\ProjectFac.rar'.

    File name: 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\ProjectFac.rar'
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at 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)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
       at ProjectFactorySerivce.Service1.UploadProject(String path) in E:\WINDOWS 8\Apps\ProjectFactorySerivce\ProjectFactorySerivce\Service1.asmx.cs:line 126
       --- End of inner exception stack trace ---

    thanks,

    prathap


    thanks, prathap


    Tuesday, April 17, 2012 5:54 AM

Answers

  • Make sure the file exists

    'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\ProjectFac.rar'

    and you have permision to read the file.


    jdweng

    Tuesday, April 17, 2012 11:10 AM
  • Hi prathap,

    2 things

    1> While creating FtpWebRequest.Create , you are building requestUriString by appending with full path , if I am not wrong this path is full local path (c:\...) , I guess this requires relative path.

    2>  It is better having check for the file existence, like

    public void uploadFile(string path)
     {
      if (!File.Exists(path))
       {
         //handle error
         return;   
       }
    
    .... //perform upload action
              

    Have look at this example 

    Hope this helps you..


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".


    Tuesday, April 17, 2012 11:32 AM

All replies

  • May be you are trying to upload a file which is not present (or renamed) at that location. Can you show us the code in uploadFile function?

    Please mark this post as answer if it solved your problem. Happy Programming!

    Tuesday, April 17, 2012 6:48 AM
  •  public void uploadFile(string path)
            {
              
                FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create("ftp://www.website.com" + "/" + path);
                req.Credentials = new NetworkCredential("username", "password");
                req.Method = WebRequestMethods.Ftp.UploadFile;
                req.UseBinary = true;
                req.KeepAlive = true;
                req.UsePassive = true;
                FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                byte[] buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);
                stream.Close();
                Stream reqStream = req.GetRequestStream();
                reqStream.Write(buffer, 0, buffer.Length);
                reqStream.Close();
            }

    thanks, prathap

    Tuesday, April 17, 2012 6:57 AM
  • Make sure the file exists

    'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\ProjectFac.rar'

    and you have permision to read the file.


    jdweng

    Tuesday, April 17, 2012 11:10 AM
  • Hi prathap,

    2 things

    1> While creating FtpWebRequest.Create , you are building requestUriString by appending with full path , if I am not wrong this path is full local path (c:\...) , I guess this requires relative path.

    2>  It is better having check for the file existence, like

    public void uploadFile(string path)
     {
      if (!File.Exists(path))
       {
         //handle error
         return;   
       }
    
    .... //perform upload action
              

    Have look at this example 

    Hope this helps you..


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".


    Tuesday, April 17, 2012 11:32 AM
  • Hi Prathap,

    Please check the path of the file. Either it is incorrect or it is missing for the mentioned location.


    Regards, http://shwetamannjain.blogspot.com

    Wednesday, April 18, 2012 2:59 AM