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

Home Posts Topics Members FAQ

File Permissions Issues

What .NET mechanism should I use to resolve permission issues before I
begin to copy directory structure/file(s) from one computer to another. I
have tried Try/Catch statement using DirectoryInfo and FileInfo but process
halts on error. The computers have Vista or XP Pro installed. Each computer
is attached to a Win 2003 or Win 2008 server.

Nov 11 '08 #1
2 2690
Good morning, Visine_Eyes.

Welcome to Microsoft Newsgroup Service. My name is Hongye Sun [MSFT] and it
is my pleasure to work with you on this issue.

This is a good question, however, it is hard to answer, because it depends
on different situations and different errors that you are facing. To better
answer this question, can you clarify the following questions for us about
the issue backgrounds?

1. What kind of application you are developing?

2. Are the computers to copy between in the same domain?

3. What is the permission error and its call stacks?

4. It would be better if sample code can be put here.

5. If there is something missing here, please feel free to let us know.

From my perspective, I have some suggestions to handle permissions in
general situations. They are just references for you before I fully
understand your situation.

1. Standard copy
In most cases, we do copy in following sequences:
a. Check if source folder / file exists.
If no, report to user.
b. Check if destination folder exists.
If no, create a new one.
c. Check if destination file exists.
If yes, override, skip or show dialog to let user decide.

We don't need to write code to check permissions before copying directories
and files. .NET Framework API already did that. For example:
FileInfo.CopyTo method will check for the read code access permission for
source destination and check for the write code access permission for
target destination before copying. If either of them is not valid, it will
throw "SecurityException" exception. It will also check the file permission
when copying, and "IOException" will be thrown.

As you mentioned, we can use Try/Catch to report errors to user and let
user to correct the permission errors manually.

Note: make sure that the account to run the application has the target
directory's write permission. Most errors are caused by this.

2. Impersonation
Sometimes that we have to copy files across domains, it requires the
current user to type another user name and password to impersonate
temporarily. It is commonly used in web application. To do that, we have to:
a. Get a token for a user
(http://alt.pluralsight.com/wiki/defa...HowToGetAToken
ForAUser.html)
b. Impersonate that user
(http://alt.pluralsight.com/wiki/defa...HowToImpersona
teAUserGivenHerToken.html)
Here is an example: http://www.codeproject.com/KB/cs/cpimpersonation1.aspx

Hope those references helps.

I will be waiting for your reply. Have a nice day.

Regards,
Hongye Sun (ho*****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 11 '08 #2
Hello Visine_Eyes,

I have not heard from you for several days since my last reply. I am
writing check the status of the issue. Would you mind letting us know any
progress from your side.

In my last reply, I was asking for background information about the issue.
That will help us to better answer your questions. In addition, I also
provided some comments on this issue for you to reference.

Please feel free to let us know if you have any problem. I will be more
than happy to help. Thanks.

Regards,
Hongye Sun (ho*****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 14 '08 #3

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

Similar topics

0
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
1
by: Chris | last post by:
I have seen the posts on various places on the internet about .NET framework mismatch issues and I don't think that is my problem. ; ) When I execute the following C++.NET code: String...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
4
by: Jason Hurder | last post by:
Hello folks, I am experiencing a rather strange problem. I have written a service that attempts to open a file on a network share via a FileStream object. When I try to open the file from my...
6
by: Pat Carden | last post by:
Hi, We need to allow webusers to upload a file on our website (on Server3, all servers run Server 2003, remotely hosted) and eventually save it on our SBS Server (Server2) which is not exposed...
2
by: Joergen Bech | last post by:
Trying to write an xml file from within a Session. Works fine if I do it in the Application_Start event of Global.asax, but not in the Page_Load event of an aspx page. If I give "Everyone" write...
3
by: JoelBrimm | last post by:
I have a batch file that executes a command line utility to do a secure file copy from our server to a 3rd party server. The batch file works fine, but when I call it from the web service the log...
2
by: James | last post by:
Hi all, I am new to ASP.NET. I am currently working on a project with VB, .NET 1.1 on a Windows 2000 server. I have two files C:\Inetpub\wwwroot\test\test.aspx...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.