473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

File Download from Network Share

Hi!

I am using impersonate="true" to upload and download files from a network
share.

I have created common users on both the webserver and the file server. The
user has permission to the files server folder.
I am able to upload the files into the fileserver, but while downloading the
same i am getting error "file doesn't exist" and the path it shows is
localhost temporary internet files.

Please help

Thanks in advance,
Nov 19 '05 #1
5 5251
Is the "localhost" location correct ? If not you'll have likely to fix how
the path is build

How do you want to download this file ? Do you want a direct link to a file
share ? My personal preference is to stream the file using the server side
page (using Response.WriteFile).

Patrice
--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:EA**********************************@microsof t.com...
Hi!

I am using impersonate="true" to upload and download files from a network
share.

I have created common users on both the webserver and the file server. The
user has permission to the files server folder.
I am able to upload the files into the fileserver, but while downloading the same i am getting error "file doesn't exist" and the path it shows is
localhost temporary internet files.

Please help

Thanks in advance,

Nov 19 '05 #2
In addition, have a look at using the WebClient class in any event. I have
experienced it's performance to be far superior to any of the other methods
of moving files.

Br,

Mark.

"Patrice" <no****@nowhere.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Is the "localhost" location correct ? If not you'll have likely to fix how
the path is build

How do you want to download this file ? Do you want a direct link to a
file
share ? My personal preference is to stream the file using the server side
page (using Response.WriteFile).

Patrice
--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:EA**********************************@microsof t.com...
Hi!

I am using impersonate="true" to upload and download files from a network
share.

I have created common users on both the webserver and the file server.
The
user has permission to the files server folder.
I am able to upload the files into the fileserver, but while downloading

the
same i am getting error "file doesn't exist" and the path it shows is
localhost temporary internet files.

Please help

Thanks in advance,


Nov 19 '05 #3
Hi! Patrice,

Thanks for the response. I am using filestream to read the file like
Dim strFilePath As String
Dim strFileName As String
Dim fsFile As FileStream
Dim strFileExtn As String
Dim strMIMEType As String
Dim lnFileSize As Long

strFileName = "XXXX_050601105406_DIA.JPG"
strFilePath = "\\<Network Server Name>\<folder
Name>\XXXX_050601105406_DIA.JPG"
strFileExtn = strFileName.Substring(strFileName.LastIndexOf(".") + 1)

Select Case strFileExtn.ToUpper()
Case "AU", "SND"
strMIMEType = "audio/basic"
Case "WAV"
strMIMEType = "audio/wav"
Case "RA", "RM", "RAM"
strMIMEType = "audio/x-pn-realaudio"
Case "MID", "MIDI"
strMIMEType = "audio/x-midi"
Case "MP3"
strMIMEType = "audio/mp3"
Case "M3U"
strMIMEType = "audio/m3u"
Case "TXT", "TEXT", "VBS", "ASP", "CGI", "PL", "NFO", "ME", "DTD"
strMIMEType = "text/plain"
Case "HTM", "HTML", "HTA", "HTX", "MHT"
strMIMEType = "text/html"
Case "JS"
strMIMEType = "text/javascript"
Case "CSS"
strMIMEType = "text/css"
Case "PDF"
strMIMEType = "application/pdf"
Case "RTF"
strMIMEType = "application/rtf"
Case "XML", "XSL", "XSLT"
strMIMEType = "text/xml"
Case "WPD"
strMIMEType = "application/wordperfect"
Case "WRI"
strMIMEType = "application/mswrite"
Case "XLS", "XLS3", "XLS4", "XLS5", "XLW"
strMIMEType = "application/msexcel"
Case "DOC"
strMIMEType = "application/msword"
Case "PPT", "PPS"
strMIMEType = "application/mspowerpoint"
Case "WML"
strMIMEType = "text/vnd.wap.wml"
Case "WMLS"
strMIMEType = "text/vnd.wap.wmlscript"
Case "WBMP"
strMIMEType = "image/vnd.wap.wbmp"
Case "WMLC"
strMIMEType = "application/vnd.wap.wmlc"
Case "WMLSC"
strMIMEType = "application/vnd.wap.wmlscriptc"
Case "GIF"
strMIMEType = "image/gif"
Case "JPG", "JPE", "JPEG"
strMIMEType = "image/jpeg"
Case "PNG"
strMIMEType = "image/png"
Case "BMP"
strMIMEType = "image/bmp"
Case "TIF", "TIFF"
strMIMEType = "image/tiff"
Case "AI", "EPS", "PS"
strMIMEType = "application/postscript"
Case "ASF"
strMIMEType = "video/x-ms-asf"
Case "AVI"
strMIMEType = "video/avi"
Case "MPG", "MPEG"
strMIMEType = "video/mpeg"
Case "QT", "MOV", "QTVR"
strMIMEType = "video/quicktime"
Case "SWA"
strMIMEType = "application/x-director"
Case "SWF"
strMIMEType = "application/x-shockwave-flash"
Case "ZIP"
strMIMEType = "application/x-zip-compressed"
Case "GZ"
strMIMEType = "application/x-gzip"
Case "RAR"
strMIMEType = "application/x-rar-compressed"
Case "COM", "EXE", "DLL", "OCX"
strMIMEType = "application/octet-stream"
Case Else
strMIMEType = "application/octet-stream"
End Select
Response.Clear()
Response.ContentType = strMIMEType
Response.AddHeader("content-disposition", "attachment;filename=" +
strFileName)
fsFile = New FileStream(strFilePath, FileMode.Open)
lnFileSize = fsFile.Length
Dim getContent(CInt(lnFileSize)) As Byte
fsFile.Read(getContent, 0, CInt(fsFile.Length))
fsFile.Close()
Response.BinaryWrite(getContent)
Response.End()

It's working fine when i am viewing a page without user authentications.

In my project, different user's have username and encrypted passwords. On
valid authentication user is allowed to go into the site. Here the problem
occours when the user is trying to view the files, whereas if user downloads
the file, its downloads properly with the correct file.

Thanks,
Baren

"Patrice" wrote:
Is the "localhost" location correct ? If not you'll have likely to fix how
the path is build

How do you want to download this file ? Do you want a direct link to a file
share ? My personal preference is to stream the file using the server side
page (using Response.WriteFile).

Patrice
--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:EA**********************************@microsof t.com...
Hi!

I am using impersonate="true" to upload and download files from a network
share.

I have created common users on both the webserver and the file server. The
user has permission to the files server folder.
I am able to upload the files into the fileserver, but while downloading

the
same i am getting error "file doesn't exist" and the path it shows is
localhost temporary internet files.

Please help

Thanks in advance,


Nov 19 '05 #4

What is the exact error ? I don't understand what you mean by "the path it
shows is localhost temporary internet files". Where do you see this name ?

For now it looks like a permission problem. Double check impersonated users
are allowed to read from this location you could,have a test page dthat even
doesn't stream)...

To stream the file you could use Response.Write. Not sure but the mimetype
could be useless (AFAIK it uses the file extension when using
"attachment;filename=..." in the header...

Good luck.

--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:ED**********************************@microsof t.com...
Hi! Patrice,

Thanks for the response. I am using filestream to read the file like
Dim strFilePath As String
Dim strFileName As String
Dim fsFile As FileStream
Dim strFileExtn As String
Dim strMIMEType As String
Dim lnFileSize As Long

strFileName = "XXXX_050601105406_DIA.JPG"
strFilePath = "\\<Network Server Name>\<folder
Name>\XXXX_050601105406_DIA.JPG"
strFileExtn = strFileName.Substring(strFileName.LastIndexOf(".") + 1)
Select Case strFileExtn.ToUpper()
Case "AU", "SND"
strMIMEType = "audio/basic"
Case "WAV"
strMIMEType = "audio/wav"
Case "RA", "RM", "RAM"
strMIMEType = "audio/x-pn-realaudio"
Case "MID", "MIDI"
strMIMEType = "audio/x-midi"
Case "MP3"
strMIMEType = "audio/mp3"
Case "M3U"
strMIMEType = "audio/m3u"
Case "TXT", "TEXT", "VBS", "ASP", "CGI", "PL", "NFO", "ME", "DTD" strMIMEType = "text/plain"
Case "HTM", "HTML", "HTA", "HTX", "MHT"
strMIMEType = "text/html"
Case "JS"
strMIMEType = "text/javascript"
Case "CSS"
strMIMEType = "text/css"
Case "PDF"
strMIMEType = "application/pdf"
Case "RTF"
strMIMEType = "application/rtf"
Case "XML", "XSL", "XSLT"
strMIMEType = "text/xml"
Case "WPD"
strMIMEType = "application/wordperfect"
Case "WRI"
strMIMEType = "application/mswrite"
Case "XLS", "XLS3", "XLS4", "XLS5", "XLW"
strMIMEType = "application/msexcel"
Case "DOC"
strMIMEType = "application/msword"
Case "PPT", "PPS"
strMIMEType = "application/mspowerpoint"
Case "WML"
strMIMEType = "text/vnd.wap.wml"
Case "WMLS"
strMIMEType = "text/vnd.wap.wmlscript"
Case "WBMP"
strMIMEType = "image/vnd.wap.wbmp"
Case "WMLC"
strMIMEType = "application/vnd.wap.wmlc"
Case "WMLSC"
strMIMEType = "application/vnd.wap.wmlscriptc"
Case "GIF"
strMIMEType = "image/gif"
Case "JPG", "JPE", "JPEG"
strMIMEType = "image/jpeg"
Case "PNG"
strMIMEType = "image/png"
Case "BMP"
strMIMEType = "image/bmp"
Case "TIF", "TIFF"
strMIMEType = "image/tiff"
Case "AI", "EPS", "PS"
strMIMEType = "application/postscript"
Case "ASF"
strMIMEType = "video/x-ms-asf"
Case "AVI"
strMIMEType = "video/avi"
Case "MPG", "MPEG"
strMIMEType = "video/mpeg"
Case "QT", "MOV", "QTVR"
strMIMEType = "video/quicktime"
Case "SWA"
strMIMEType = "application/x-director"
Case "SWF"
strMIMEType = "application/x-shockwave-flash"
Case "ZIP"
strMIMEType = "application/x-zip-compressed"
Case "GZ"
strMIMEType = "application/x-gzip"
Case "RAR"
strMIMEType = "application/x-rar-compressed"
Case "COM", "EXE", "DLL", "OCX"
strMIMEType = "application/octet-stream"
Case Else
strMIMEType = "application/octet-stream"
End Select
Response.Clear()
Response.ContentType = strMIMEType
Response.AddHeader("content-disposition", "attachment;filename=" +
strFileName)
fsFile = New FileStream(strFilePath, FileMode.Open)
lnFileSize = fsFile.Length
Dim getContent(CInt(lnFileSize)) As Byte
fsFile.Read(getContent, 0, CInt(fsFile.Length))
fsFile.Close()
Response.BinaryWrite(getContent)
Response.End()

It's working fine when i am viewing a page without user authentications.

In my project, different user's have username and encrypted passwords. On
valid authentication user is allowed to go into the site. Here the problem
occours when the user is trying to view the files, whereas if user downloads the file, its downloads properly with the correct file.

Thanks,
Baren

"Patrice" wrote:
Is the "localhost" location correct ? If not you'll have likely to fix how the path is build

How do you want to download this file ? Do you want a direct link to a file share ? My personal preference is to stream the file using the server side page (using Response.WriteFile).

Patrice
--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:EA**********************************@microsof t.com...
Hi!

I am using impersonate="true" to upload and download files from a network share.

I have created common users on both the webserver and the file server. The user has permission to the files server folder.
I am able to upload the files into the fileserver, but while
downloading the
same i am getting error "file doesn't exist" and the path it shows is
localhost temporary internet files.

Please help

Thanks in advance,


Nov 19 '05 #5
Hi! Patrice

Thanks for the reply. I am able to solve the problem. I had this code
Response.Cache.SetCacheability(HttpCacheability.No Cache) which was causing
the problem. Now i commented the line and its working fine.

Thanks again
Baren

"Patrice" wrote:

What is the exact error ? I don't understand what you mean by "the path it
shows is localhost temporary internet files". Where do you see this name ?

For now it looks like a permission problem. Double check impersonated users
are allowed to read from this location you could,have a test page dthat even
doesn't stream)...

To stream the file you could use Response.Write. Not sure but the mimetype
could be useless (AFAIK it uses the file extension when using
"attachment;filename=..." in the header...

Good luck.

--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:ED**********************************@microsof t.com...
Hi! Patrice,

Thanks for the response. I am using filestream to read the file like
Dim strFilePath As String
Dim strFileName As String
Dim fsFile As FileStream
Dim strFileExtn As String
Dim strMIMEType As String
Dim lnFileSize As Long

strFileName = "XXXX_050601105406_DIA.JPG"
strFilePath = "\\<Network Server Name>\<folder
Name>\XXXX_050601105406_DIA.JPG"
strFileExtn = strFileName.Substring(strFileName.LastIndexOf(".") +

1)

Select Case strFileExtn.ToUpper()
Case "AU", "SND"
strMIMEType = "audio/basic"
Case "WAV"
strMIMEType = "audio/wav"
Case "RA", "RM", "RAM"
strMIMEType = "audio/x-pn-realaudio"
Case "MID", "MIDI"
strMIMEType = "audio/x-midi"
Case "MP3"
strMIMEType = "audio/mp3"
Case "M3U"
strMIMEType = "audio/m3u"
Case "TXT", "TEXT", "VBS", "ASP", "CGI", "PL", "NFO", "ME",

"DTD"
strMIMEType = "text/plain"
Case "HTM", "HTML", "HTA", "HTX", "MHT"
strMIMEType = "text/html"
Case "JS"
strMIMEType = "text/javascript"
Case "CSS"
strMIMEType = "text/css"
Case "PDF"
strMIMEType = "application/pdf"
Case "RTF"
strMIMEType = "application/rtf"
Case "XML", "XSL", "XSLT"
strMIMEType = "text/xml"
Case "WPD"
strMIMEType = "application/wordperfect"
Case "WRI"
strMIMEType = "application/mswrite"
Case "XLS", "XLS3", "XLS4", "XLS5", "XLW"
strMIMEType = "application/msexcel"
Case "DOC"
strMIMEType = "application/msword"
Case "PPT", "PPS"
strMIMEType = "application/mspowerpoint"
Case "WML"
strMIMEType = "text/vnd.wap.wml"
Case "WMLS"
strMIMEType = "text/vnd.wap.wmlscript"
Case "WBMP"
strMIMEType = "image/vnd.wap.wbmp"
Case "WMLC"
strMIMEType = "application/vnd.wap.wmlc"
Case "WMLSC"
strMIMEType = "application/vnd.wap.wmlscriptc"
Case "GIF"
strMIMEType = "image/gif"
Case "JPG", "JPE", "JPEG"
strMIMEType = "image/jpeg"
Case "PNG"
strMIMEType = "image/png"
Case "BMP"
strMIMEType = "image/bmp"
Case "TIF", "TIFF"
strMIMEType = "image/tiff"
Case "AI", "EPS", "PS"
strMIMEType = "application/postscript"
Case "ASF"
strMIMEType = "video/x-ms-asf"
Case "AVI"
strMIMEType = "video/avi"
Case "MPG", "MPEG"
strMIMEType = "video/mpeg"
Case "QT", "MOV", "QTVR"
strMIMEType = "video/quicktime"
Case "SWA"
strMIMEType = "application/x-director"
Case "SWF"
strMIMEType = "application/x-shockwave-flash"
Case "ZIP"
strMIMEType = "application/x-zip-compressed"
Case "GZ"
strMIMEType = "application/x-gzip"
Case "RAR"
strMIMEType = "application/x-rar-compressed"
Case "COM", "EXE", "DLL", "OCX"
strMIMEType = "application/octet-stream"
Case Else
strMIMEType = "application/octet-stream"
End Select
Response.Clear()
Response.ContentType = strMIMEType
Response.AddHeader("content-disposition", "attachment;filename=" +
strFileName)
fsFile = New FileStream(strFilePath, FileMode.Open)
lnFileSize = fsFile.Length
Dim getContent(CInt(lnFileSize)) As Byte
fsFile.Read(getContent, 0, CInt(fsFile.Length))
fsFile.Close()
Response.BinaryWrite(getContent)
Response.End()

It's working fine when i am viewing a page without user authentications.

In my project, different user's have username and encrypted passwords. On
valid authentication user is allowed to go into the site. Here the problem
occours when the user is trying to view the files, whereas if user

downloads
the file, its downloads properly with the correct file.

Thanks,
Baren

"Patrice" wrote:
Is the "localhost" location correct ? If not you'll have likely to fix how the path is build

How do you want to download this file ? Do you want a direct link to a file share ? My personal preference is to stream the file using the server side page (using Response.WriteFile).

Patrice
--

"Baren" <Ba***@discussions.microsoft.com> a écrit dans le message de
news:EA**********************************@microsof t.com...
> Hi!
>
> I am using impersonate="true" to upload and download files from a network > share.
>
> I have created common users on both the webserver and the file server. The > user has permission to the files server folder.
> I am able to upload the files into the fileserver, but while downloading the
> same i am getting error "file doesn't exist" and the path it shows is
> localhost temporary internet files.
>
> Please help
>
> Thanks in advance,


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: moonriver | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004...
8
by: Lam | last post by:
HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve,...
3
by: Frank Hofmann | last post by:
Hi there, I'm new to .Net and programming of web sites. But I have to build a solution which can do the following: Only authorized people can connect to a specific site. They have to login...
11
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
1
by: Bala | last post by:
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...
4
by: abhanjee | last post by:
Hello, I am a newbie and am developing an application for work. I have figured out how to upload a file attachment to the SQL database and download the same file using C# and Visual Studio....
0
by: Dom Rout | last post by:
Hello. Well, this is my first post on any USENET group anywhere, so I hope I get it right. Basically, I just want to get some opinions on a plan of mine for a new project. I want to produce a...
0
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, We have a legacy asp application that uses a third party component to upload a file and saves it to a secure network share. The code sets the credentials for the secure network share on the...
0
by: cw808 | last post by:
Hi all. I'm new here but hoping I can get some help for my problem. My situation is that I need to upload files through a C# .NET web application to a file server. I done a search and followed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.