accessing file on network machine

Discussion in 'ASP .Net' started by =?Utf-8?B?QmFsYQ==?=, Aug 26, 2005.

  1. 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
    =?Utf-8?B?QmFsYQ==?=, Aug 26, 2005
    #1
    1. Advertising

  2. 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

    "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
    =?Utf-8?B?QmFsYQ==?=, Aug 26, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?QmFsYQ==?=

    Julia

    Joined:
    Sep 20, 2006
    Messages:
    1
    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.
    Julia, Nov 7, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tola
    Replies:
    29
    Views:
    1,001
    Mark McIntyre
    Dec 28, 2003
  2. Nico Grubert
    Replies:
    1
    Views:
    2,590
    Markus Rosenstihl
    Sep 21, 2005
  3. Steve Holden
    Replies:
    0
    Views:
    403
    Steve Holden
    Sep 21, 2005
  4. Replies:
    9
    Views:
    10,188
  5. PerlFAQ Server
    Replies:
    0
    Views:
    114
    PerlFAQ Server
    Apr 9, 2011
Loading...

Share This Page