accessing file on network machine

G

Guest

Hi

Currently I am displaying the list of files name on my datagrid. The files
physcially stored on network machine call TestMachine, not in the webserver.
r
In grid the file path says "file:\\Testmachine\Arc\Folders\test.pdf"

I already created the username and password for those folder and
Impersonating. thats working fine. after impersonating when i try to access
that file i am getting this error.



'Logon failure: unknown user name or bad password.'

I am using the below code for downloading file.

In that fucntion still the below line, its working fine. when i comment the
below line its download files.but all files are junk.

Response.WriteFile(path1)

thanks
bala

Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As
Boolean)
Dim path1 As String = fname
Dim name As String = Path.GetFileName(path1)

Dim ext As String = Path.GetExtension(path1)
Dim type As String = ""
If Not (ext Is Nothing) Then
Select Case ext.ToLower
Case ".htm", ".html"
type = "text/HTML"
' break
Case ".txt"
type = "text/plain"
' break
Case ".doc", ".rtf"
type = "Application/msword"
' break
Case ".pdf"
type = "Application/pdf"
End Select
End If
If forceDownload Then
Response.AppendHeader("content-disposition", "attachment;
filename=" + name)
End If
If Not (type = "") Then
Response.ContentType = type
End If
Response.WriteFile(path1)
Response.End()
End Sub
 
G

Guest

This is the actual error message.

[IOException: Logon failure: unknown user name or bad password.
]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +723
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share) +45
System.Web.HttpResponse.TransmitFile(String filename) +119
stest.nsScanfiles.stest.WebForm2.DownloadFile(String fname, Boolean
forceDownload)
stest.nsScanfiles.stest.WebForm2.Button1_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

thanks
bala
 
Joined
Sep 19, 2006
Messages
1
Reaction score
0
I'm also facing the same problem

Have ur problem already solved out?
I'm also facing the same problem when i try to download files that is resides on another machine under same domain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,262
Messages
2,571,043
Members
48,769
Latest member
Clifft

Latest Threads

Top