H
HNguyen
Hi,
I have a Web application in ASP.NET. My Application allows the users upload
files into the server after checking their user names and passwords. For
each transaction, the Web program will write the information about user
name, filename upload, filesize, date and time of uploading into the log
file. (The name of the log file is constructed by Current Year and Current
Month in my program). Is there any problems with writing into the log file
if there are multi-users access on the same page to upload files ????. My
program works OK with the code below, but I don't know if there is any
problems when multi-users perform writing into the same log file at the same
time ??? Here is a part of my code to open the log file for editing :
'WRITE LO LOG FILE
Dim strFile as string= CurrYear & CurrMonth
Dim LogFile As String = Server.MapPath("LOGS") & "\" & strFile &
".log"
Dim aLogfile As FileInfo = New FileInfo(LogFile)
If aLogfile.Exists Then
Dim objStreamWriter as StreamWriter
objStreamWriter = File.AppendText(LogFile)
Dim strLine as string= CurrYear & CurrMonth & CurrDay &
CurrHour & CurrMin & CurrSec & " " & radioFileUp.selectedValue & " " &
Session("UserID") & " " & Carrier & " " & fn & " " & fsize & " bytes "
objStreamWriter.WriteLine(strLine)
objStreamWriter.Close()
Else
Dim objStreamWriter as StreamWriter = File.CreateText(LogFile)
Dim strLine as string= CurrYear & CurrMonth & CurrDay &
CurrHour & CurrMin & CurrSec & " " & radioFileUp.selectedValue & " " &
Session("UserID") & " " & Carrier & " " & fn & " " & fsize & " bytes "
objStreamWriter.WriteLine(strLine)
objStreamWriter.Close()
End If
Please give me some advises. Do I need to change anything in my code for it
?. Thanks in advance.
I have a Web application in ASP.NET. My Application allows the users upload
files into the server after checking their user names and passwords. For
each transaction, the Web program will write the information about user
name, filename upload, filesize, date and time of uploading into the log
file. (The name of the log file is constructed by Current Year and Current
Month in my program). Is there any problems with writing into the log file
if there are multi-users access on the same page to upload files ????. My
program works OK with the code below, but I don't know if there is any
problems when multi-users perform writing into the same log file at the same
time ??? Here is a part of my code to open the log file for editing :
'WRITE LO LOG FILE
Dim strFile as string= CurrYear & CurrMonth
Dim LogFile As String = Server.MapPath("LOGS") & "\" & strFile &
".log"
Dim aLogfile As FileInfo = New FileInfo(LogFile)
If aLogfile.Exists Then
Dim objStreamWriter as StreamWriter
objStreamWriter = File.AppendText(LogFile)
Dim strLine as string= CurrYear & CurrMonth & CurrDay &
CurrHour & CurrMin & CurrSec & " " & radioFileUp.selectedValue & " " &
Session("UserID") & " " & Carrier & " " & fn & " " & fsize & " bytes "
objStreamWriter.WriteLine(strLine)
objStreamWriter.Close()
Else
Dim objStreamWriter as StreamWriter = File.CreateText(LogFile)
Dim strLine as string= CurrYear & CurrMonth & CurrDay &
CurrHour & CurrMin & CurrSec & " " & radioFileUp.selectedValue & " " &
Session("UserID") & " " & Carrier & " " & fn & " " & fsize & " bytes "
objStreamWriter.WriteLine(strLine)
objStreamWriter.Close()
End If
Please give me some advises. Do I need to change anything in my code for it
?. Thanks in advance.