Cant Access File because it is being used by another process

前端 未结 6 2148
我寻月下人不归
我寻月下人不归 2020-12-11 09:25

I have an ASP.NET program where i am downloading a file from web using DownloadFile method of webClient Class and the do some modifications on it. then i am Saving it to ano

6条回答
  •  悲&欢浪女
    2020-12-11 10:25

    this may help....sorry its VB not C but hey...

    This works

        Dim fs As FileStream = Nothing
        fs = File.Create("H:\test.txt")
        fs.Close()
        File.Delete("H:\test.txt")
    

    This doesn't, give "file being used by another process" error

        File.Create("H:\test.txt")
        File.Delete("H:\test.txt")
    

提交回复
热议问题