To piggy back off of what sallushan said, We would like to see what the
particular error is so we would know where to look, and "this" is the
keyword that has the same functionality as "My" in C#. Sara using the "try",
"catch", and "finally" statement to trap any exception when opening a file
or a connection because if sometihing goes wrong and the program throws an
exception you can potentially run out of file handles or leave a database
connection open which is a security risk. Place exceptions within these
statements.

On Thu, Sep 25, 2008 at 3:10 PM, sallushan <[EMAIL PROTECTED]> wrote:

>
> You haven't mentioned, what and where the exception is occuring? I
> don't know whether you are doing is the only way in C# or NOT, but we
> have a very simple thing in Visual Basic i.e. "My". You can use it in
> C# too. Add a reference to Microsoft.VisualBasic, then use the
> following code to upload file,
>
> Microsoft.VisualBasic.Devices.Network n;
> n = new Microsoft.VisualBasic.Devices.Network();
> n.UploadFile("C:\\TestFile.txt", "ftp://www.mydomain.com/
> testfile.txt", "userid", "password", true, 100);
>
> where,
> true = display UI (progress) while uploading the file
> 100 = connection timeout in milliseconds
>
> Above 3 lines will (inshaALLAH) upload the file with a UI displaying
> the progress of uploading!
>
>
> On Sep 25, 3:26 pm, sara <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> >          i am developing the tool that i want to transfer the file
> > from local to remote. when i run the aplicatioon it shows some error.
> > the below code i m using..
> >
> >  //string filename = "c:\\test.xls";
> >             FileInfo fileInf = new FileInfo("c:\\test.xls");
> >             string uri = "ftp://"; + "Ipaddress" + "/" + fileInf.Name;
> >             FtpWebRequest reqFTP = (FtpWebRequest)
> > FtpWebRequest.Create(uri);
> >             //HttpWebRequest reqFTP = (HttpWebRequest)
> > HttpWebRequest.Create(uri);
> >
> >             reqFTP.Credentials = new NetworkCredential("username",
> > "password","domain");
> >             reqFTP.KeepAlive = false;
> >             reqFTP.Proxy = null;
> >
> >             reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
> >             //reqFTP.Method =  WebRequestMethods.Http.Post;
> >             //reqFTP.uUseBinary = true;
> >             reqFTP.ContentLength = fileInf.Length;
> >
> >             int buffLength = 2048;
> >             byte[] buff = new byte[buffLength];
> >             int contentLen;
> >             FileStream fs = fileInf.OpenRead();
> >
> >                 // Stream to which the file to be upload is written
> >                 Stream strm = reqFTP.GetRequestStream();
> >
> >                 // Read from the file stream 2kb at a time
> >                 contentLen = fs.Read(buff, 0, buffLength);
> >
> >                 // Till Stream content ends
> >                 while (contentLen != 0)
> >                 {
> >                     // Write Content from the file stream to the FTP
> > Upload
> >                     // Stream
> >                     strm.Write(buff, 0, contentLen);
> >                     contentLen = fs.Read(buff, 0, buffLength);
> >                 }
> >
> >                 // Close the file stream and the Request Stream
> >                 strm.Close();
> >                 fs.Close();
> >
> > please any one can help me to finish this task
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

Reply via email to