private void WriteToFile(Stream st, string path)
{
try
{
CreateFoler(path);
using (Stream fs = new System.IO.FileStream(path, System.IO.FileMode.CreateNew))
{
long totalDownloadedByte = 0;
byte[] buffer = new byte[1024];
int osize = st.Read(buffer, 0, (int)buffer.Length);
while (osize > 0)
{
totalDownloadedByte = osize + totalDownloadedByte;
fs.Write(buffer, 0, osize);
osize = st.Read(buffer, 0, (int)buffer.Length);
}
}
}
catch (WebException ex)
{
Logger.Write(path.ToString() + "\r\n" + ex);
}
}