473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Working with files in network drives

igg
I'm developing a .net application and I need to save files in a network
drive. I need to create a subdirectory and I've tried this:

Directory.SetCurrentDirectory(Path);

Directory.CreateDirectory("folder1");

I've tried with values of 'Path' like "Z:\Dir", "\\remoteserver\Dir", ... (Z
the mapped unit and remoteserver the name of the remote machine) but seems
that the class Directory can't work with remote drives.

Any idea?

Thanks

Nov 15 '05 #1
4 15633
Is this a service app or a winform app? If it's a winform app, do you as a
user have permission to create directories on this network drive?

If it's a service app, you might need to provide access rights to that
account. I don't really know how that is done, though.

Pete
--
http://www.petedavis.net
"igg" <a@a.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I'm developing a .net application and I need to save files in a network
drive. I need to create a subdirectory and I've tried this:

Directory.SetCurrentDirectory(Path);

Directory.CreateDirectory("folder1");

I've tried with values of 'Path' like "Z:\Dir", "\\remoteserver\Dir", ... (Z the mapped unit and remoteserver the name of the remote machine) but seems
that the class Directory can't work with remote drives.

Any idea?

Thanks

Nov 15 '05 #2

Hi igg,

Thank you for posting in the community!

Based on my understanding, you can use directory to access the local drive,
but when you access a network drive, it failed.

================================
I agree with Pete that this problem may due to security permission.

When you use your code, which exception expression it shows? Please use
try...catch to show the error message for us.

In MSDN you can see that Directory.SetCurrentDirectory need
FileIOPermissionAccess.Write permission, while Directory.CreateDirectory
needs FileIOPermissionAccess.Read and FileIOPermissionAccess.Write
permission.

You may check the permission for your network drive.

===============================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
igg
To Pete Davis: is a web application (asp.net) so perhaps I would have to
configure the permissions of the aspnet account. I've tried it, but without
success yet.

To Jeffrey: the exception is System.IO.DirectoryNotFoundException. I have
the framework in spanish so the message is 'No se puede encontrar una parte
de la ruta de acceso "Z:/".'. It's more or less like ' A part of path "Z:/"
can't be found'

The path that I use is "Z:/Dir" (Z the drive mapped and Dir the remote
directory shared). When I change it with "C:/Dir" it works perfectly.

Thanks in advance
"""Jeffrey Tan[MSFT]""" <v-*****@online.microsoft.com> escribió en el
mensaje news:1O****************@cpmsftngxa06.phx.gbl...

Hi igg,

Thank you for posting in the community!

Based on my understanding, you can use directory to access the local drive, but when you access a network drive, it failed.

================================
I agree with Pete that this problem may due to security permission.

When you use your code, which exception expression it shows? Please use
try...catch to show the error message for us.

In MSDN you can see that Directory.SetCurrentDirectory need
FileIOPermissionAccess.Write permission, while Directory.CreateDirectory
needs FileIOPermissionAccess.Read and FileIOPermissionAccess.Write
permission.

You may check the permission for your network drive.

===============================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
Hi Igg,

As far as I know, mapped drives are user account specific. In other words,
if you configure a mapped drive with user A, and log on with user B, user B
is not able to use the mapped drive.

The key point here is that ASP.Net worker process runs under the account
ASPNET. As a result, the worker process knows nothing about drive "Z:" that
is configured with your current user account.

I would suggest that you still use the UNC path (e.g. \\server\share). You
need to configure carefully with the share permissions and NTFS permissions
on the remote server. I believe the following article will be useful to you:

ASP.NET Security
http://msdn.microsoft.com/library/de...us/dnnetsec/ht
ml/SecNetch08.asp

You may refer to the section "Accessing Network Resources" and "Accessing
Files on a UNC File Share".

I hope this helps.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

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

Similar topics

2
by: Jim Richards | last post by:
I have been told by a local PC club technician that 98SE cannot read NTFS drives in a network. Is this true? TIA, Jim.
8
by: Claudio Grondi | last post by:
It is maybe not a pure Python question, but I think it is the right newsgroup to ask for help, anyway. After connecting a drive to the system (via USB or IDE) I would like to be able to see...
1
by: BuddyWork | last post by:
Hello, I need to know how I can check if the drives on my machine are network drives and local drives via the .Net framework. For example my PC has the following drives C: Local D: Local N:...
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
2
by: Pradeep Sundaram(MSFT) | last post by:
Hello, I want to enumerate all the Drives on the web server using ASP.NET (C#) Writing code like this works when i use local host but when i try to access it from another machine it does not show...
1
by: Dennis | last post by:
I use the below code to get the Network Places items. However, this requires "Late Binding". I read that you can avoid late binding by adding a reference to the Com Types in your application. ...
0
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
1
by: CrimeMaster | last post by:
I have write some simple code,this code does not shows network mapped drives when we run it under system account, otherwise under user account it shows them correctly. Any body tell me why did...
2
by: =?Utf-8?B?ZGdjb29wZXI=?= | last post by:
When I get a list of drives using the Directory.GetLogicalDrives(), it gives me all drives including disconnected network drives. When I attempt to use Directory.GetDirectories() on a disconnected...
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...
1
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.