Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > accessing file on network machine

Reply
Thread Tools

accessing file on network machine

 
 
=?Utf-8?B?QmFsYQ==?=
Guest
Posts: n/a
 
      08-26-2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFsYQ==?=
Guest
Posts: n/a
 
      08-26-2005
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(Stri ng fname, Boolean
forceDownload)
stest.nsScanfiles.stest.WebForm2.Button1_Click(Obj ect sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

thanks
bala

"Bala" wrote:

> 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

 
Reply With Quote
 
 
 
 
Julia Julia is offline
Junior Member
Join Date: Sep 2006
Posts: 1
 
      11-07-2006
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.6 How do I download a file from the user's machine? How do I open a file on another machine? PerlFAQ Server Perl Misc 0 04-09-2011 04:00 PM
Vist Machine cannot see XP machine on Network sr19 Wireless Networking 1 01-19-2010 03:19 AM
How to copy a file from one machine to another machine Nico Grubert Python 1 09-21-2005 10:53 AM
Re: How to copy a file from one machine to another machine Steve Holden Python 0 09-21-2005 10:29 AM



Advertisments