[RESOLVED] Write filestream to an FTP path
I need to write a filestream to an FTP path. Is this possible? Am I just doing it wrong? :confused:
FTP path =
Code:
FTP://username:password@###.###.###.###/foldername/file.docx
C# (Hope that does not matter) Code is as follows:
Code:
public Boolean CopyDoc(string OldDoc, string NewDoc)
{
try
{
byte[] byteArray = File.ReadAllBytes(OldDoc);
using (MemoryStream mem = new MemoryStream())
{
mem.Write(byteArray, 0, (int)byteArray.Length);
using (FileStream fileStream = new FileStream(NewDoc,
System.IO.FileMode.CreateNew))
{
mem.WriteTo(fileStream);
}
}
return true;
}
catch (IOException e)
{
string myerrmsg = "The file '" + NewDoc + "' already exists.";
if (e.Message == myerrmsg)
{
throw new IOException(myerrmsg);
}
else
{
throw new IOException(e.Message);
}
return false;
}
catch (Exception e)
{
throw new Exception(e.Message);
return false;
}
}
Error i get:
Code:
The given path's format is not supported.
Re: Write filestream to an FTP path
Quote:
Originally Posted by
kul2bme
C# (Hope that does not matter)
Not to me it doesn't :)
The error message would suggest that there is something not quite right with the path that you are trying to write to.
Have you tried stepping through the code with the debugger? Have you checked that any path that you are creating is correct and valid, and what you expect it to be?
You might be interested in taking a look at the following:
http://www.vbforums.com/showthread.p...&highlight=ftp
Hope that helps!!
Gary
Re: Write filestream to an FTP path
Thanks Gary! The link you provided was just what I needed. Works like a champ as is. :thumb:
Re: [RESOLVED] Write filestream to an FTP path
Hey,
Good stuff, glad to hear it!!
Gary