开发者

when i try to save this file it creates and folder for the entire path

ZipFileToCreate = "c:\user\desktop\webservice\file.zip";

So, when i try to save this file it creates the f开发者_如何学Goolder for the path like user\desktop\webservice\file\

Why is it so?

FileStream fs = new FileStream(ZipFileToCreate, FileMode.Open);
byte[] data = new Byte[fs.Length];
BinaryReader br = new BinaryReader(fs);
br.Read(data, 0, data.Length);
br.Close();
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
Response.AppendHeader("Content-Disposition", "filename=" + Parameter + ".zip");
DeleteOldFiles();
Response.BinaryWrite(data);


I think you need to be using the Environment.GetFolderPath method to find the current users' Desktop folder rather than hard-coding "c:\user\desktop\webservice\file.zip". Also using Path.Combine to build a path is more reliable than string concatenation. Try

Parameter = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "file.zip");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜