473,394 Members | 1,869 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,394 software developers and data experts.

ASP.Net writing to files on a different server

How can I write a file to a mapped drive on a different
server, from an ASP.Net application?

Thanks

Helen
Jul 21 '05 #1
3 3848
Hi Helen,

Thanks for your post. As I understand, your server with IIS has a drive
mapped to a different server. Now you want to write to a file in the mapped
drive in your ASP .NET application on the server. Please correct me if
there is any misunderstanding. I now share the following information with
you:

1. As you know, the codebehind of .aspx page are server side code that will
be executed on your IIS server. As in this case, you can use File class in
..NET class library to access the file in the mapped drive. Please refer to
MSDN documentation on File class:

File Class
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemIOFileClassTopic.asp

2. In addition, please make sure that your ASPNET account have enough
permissions to access the mapped folder and file. If not, you can either
set the folder's security properties manually or impersonate another user
account which has enough prevelidges in your ASP .NET Web application.

INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?id=306158

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hi Huang,
Thanks for that. I've tried changing the user id and
password in the machine.config, to an account that
definitely has access to read and write to the mapped
drive, as I can use it no problem from windows explorer,
but I'm still having problems.

My code works fine when I write the file to a local
directory, but when I change to the mapped directory the
error I'm getting is:

[DirectoryNotFoundException: Could not find a part of the
path "Y:\Sreqimport\Websitesreq.xml".]
System.IO.__Error.WinIOError(Int32 errorCode, String
str) +287
System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share, Int32 bufferSize,
Boolean useAsync, String msgPath, Boolean bFromProxy) +859
System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) +45
System.Xml.XmlTextWriter..ctor(String filename,
Encoding encoding)
System.Xml.XmlDOMTextWriter..ctor(String filename,
Encoding encoding)
System.Xml.XmlDocument.Save(String filename)
FlareCityCouncil.XMLAdapter.FlareEntity.Save() in
c:\inetpub\wwwroot\flare\flarecitycouncil\xmladapt er\flaree
ntity.cs:91

FlareCityCouncil.ServiceRequests.SRAdd.Submit1_Ser verClick
(Object sender, EventArgs e) in
c:\inetpub\wwwroot\flare\flarecitycouncil\servicer equests\s
radd.aspx.cs:93
System.Web.UI.HtmlControls.HtmlInputButton.OnServe rClick
(EventArgs e)

System.Web.UI.HtmlControls.HtmlInputButton.System. Web.UI.IP
ostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent
(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent
(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Any other thoughts?

Thanks ..
Helen
-----Original Message-----
Hi Helen,

Thanks for your post. As I understand, your server with IIS has a drivemapped to a different server. Now you want to write to a file in the mappeddrive in your ASP .NET application on the server. Please correct me ifthere is any misunderstanding. I now share the following information withyou:

1. As you know, the codebehind of .aspx page are server side code that willbe executed on your IIS server. As in this case, you can use File class in.NET class library to access the file in the mapped drive. Please refer toMSDN documentation on File class:

File Class
http://msdn.microsoft.com/library/default.asp? url=/library/en-us/cpref/html/frlrfSystemIOFileClassTopic.asp

2. In addition, please make sure that your ASPNET account have enoughpermissions to access the mapped folder and file. If not, you can eitherset the folder's security properties manually or impersonate another useraccount which has enough prevelidges in your ASP .NET Web application.
INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?id=306158

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #3
Hello Helen,

Thanks for your response.

Based on my experience, you should also give the file share FullTrust
permission as described in the MSDN article below and check whether or the
problem still exists.

http://msdn.microsoft.com/library/de...us/vsintro7/ht
ml/vxurfprojectfoldernotsecuredialogbox.asp

I look forward to your result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4

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

Similar topics

6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
13
by: Jeff Pritchard | last post by:
I have an MDB that contains a single table. Checkweigher data is being continuously written to this MDB from a dedicated workstation over a network into the MDB on the server at the rate of about...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
28
by: SzH | last post by:
Suppose that there is a program that takes two files as its command line arguments. Is there a (cross platform) way to decide whether the two files are the same? Simple string comparison is not...
11
by: Krzysztof Retel | last post by:
Hi guys, I am struggling writing fast UDP server. It has to handle around 10000 UDP packets per second. I started building that with non blocking socket and threads. Unfortunately my approach...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.