PDA

View Full Version : Creating Word Document in ASP.NET Some Temp files creating ......


senthilavs
06-14-2006, 11:10 AM
Hi,

In ASP.NET im creating the word document. While document is creating some temp file is creating. So at that time i can't able to down load the file from server machine to client machine.
Eg.
Word File Name : "Endoscopy_2_49_5.doc"
Temp File Name : "~$doscopy_2_49_5.doc"

Error Occurs:
------------------
The process cannot access the file "<path>" because it is being used by another process.

Here im creating the Word Document in the Server Machine. After that from Client Machine im down load the file and do some correction and updating to server. How to over come this one.

Thanks in advance,
Senthil V.

otaku149
06-15-2006, 02:13 PM
I had the same problem last year but with a .txt file. I fixed the problem using the StreamReader Class.


Imports System.IO

Dim FileName As String = Server.MapPath("myFile.txt")
Dim FileContents As String
Dim myStreamReader As StreamReader

Try
myStreamReader = File.OpenText(FileName)
FileContents = myStreamReader.ReadToEnd()
lblContent.Text = FileContents
Catch ex As Exception
If Not myStreamReader Is Nothing Then
lblContent.Text = ex.Message
End If
Finally
myStreamReader.Close()
End Try