G
Guest
I'm trying to read and write files in a web folder. I've succeeded in downloading a file from a web folder using the following code. However, I'm unsure as how to copy a file up to the server
Also, is there a way to determine the file attributes without downloading the file etc
private bool CopyFileFromWeb(string from, string to, int bufferSize
bool bOK = false
FileStream file = null
WebRequest req = WebRequest.Create(from)
try
WebResponse result = req.GetResponse()
Stream ReceiveStream = result.GetResponseStream()
Byte[] read = new Byte[bufferSize]
int bytes = ReceiveStream.Read(read, 0, bufferSize)
// open the destination strea
file = new FileStream(to,FileMode.CreateNew,FileAccess.Write)
while (bytes > 0
file.Write(read,0,bytes)
bytes = ReceiveStream.Read(read, 0, bufferSize)
bOK = true
}
catch(Exception exc)
// deal with error her
finall
if (file != null
file.Close()
return bOK
}
Also, is there a way to determine the file attributes without downloading the file etc
private bool CopyFileFromWeb(string from, string to, int bufferSize
bool bOK = false
FileStream file = null
WebRequest req = WebRequest.Create(from)
try
WebResponse result = req.GetResponse()
Stream ReceiveStream = result.GetResponseStream()
Byte[] read = new Byte[bufferSize]
int bytes = ReceiveStream.Read(read, 0, bufferSize)
// open the destination strea
file = new FileStream(to,FileMode.CreateNew,FileAccess.Write)
while (bytes > 0
file.Write(read,0,bytes)
bytes = ReceiveStream.Read(read, 0, bufferSize)
bOK = true
}
catch(Exception exc)
// deal with error her
finall
if (file != null
file.Close()
return bOK
}