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

Home Posts Topics Members FAQ

Copying files Permission

I am copying a file from a network drive to a local PC.
Could someone give me a short example on how to get permission to copy the
file from R: to C:
I have figured out that if I use
Imports System.Security.Permissions

and

Dim oFp As FileIOPermission = New _

FileIOPermission(FileIOPermissionAccess.AllAccess, "R: ....

Am I on the track?

regards

reidarT
Nov 17 '05 #1
6 2597
ReidarT,

You can't really give yourself permissions if you don't have them
already.

You can use the FileIOPermission class to determine whether or not you
have the permission (based on where your app was loaded from).

What you would do is create an instance of the FileIOPermission
instance, passing the complete paths of the file names you want to move
(with read access for the file being copied, and write access for the file
being copied to).

Once you have that, you can call Demand on the permission, and it will
throw a security exception if the framework will permit you to make the
call.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ReidarT" <re****@eivon.no> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I am copying a file from a network drive to a local PC.
Could someone give me a short example on how to get permission to copy the
file from R: to C:
I have figured out that if I use
Imports System.Security.Permissions

and

Dim oFp As FileIOPermission = New _

FileIOPermission(FileIOPermissionAccess.AllAccess, "R: ....

Am I on the track?

regards

reidarT

Nov 17 '05 #2
Could you please give me an example
regards
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:%2****************@TK2MSFTNGP10.phx.gbl...
I am copying a file from a network drive to a local PC.
Could someone give me a short example on how to get permission to copy the
file from R: to C:
I have figured out that if I use
Imports System.Security.Permissions

and

Dim oFp As FileIOPermission = New _

FileIOPermission(FileIOPermissionAccess.AllAccess, "R: ....

Am I on the track?

regards

reidarT

Nov 17 '05 #3
Hi! Were you able to get it working? I am faced with the same problem.
If you were, may I ask you to post the code here, please.

Many Thanks in Advance

"reidarT" wrote:
Could you please give me an example
regards
reidarT

"ReidarT" <re****@eivon.no> skrev i melding
news:%2****************@TK2MSFTNGP10.phx.gbl...
I am copying a file from a network drive to a local PC.
Could someone give me a short example on how to get permission to copy the
file from R: to C:
I have figured out that if I use
Imports System.Security.Permissions

and

Dim oFp As FileIOPermission = New _

FileIOPermission(FileIOPermissionAccess.AllAccess, "R: ....

Am I on the track?

regards

reidarT


Nov 17 '05 #4
Could you say you got UnauthorizedAccessException or SecurityException?

Nov 17 '05 #5
Hi! I am getting both

"Truong Hong Thi" wrote:
Could you say you got UnauthorizedAccessException or SecurityException?

Nov 17 '05 #6
Hi Mike,

UnauthorizedAccessException: the only way to avoid this is not in your
code. Ask an admin on that machine to grant more permission (ACL) for
you (i.e. the account you logged in on the local computer) on the file
to copy.

SecurityException: Adjust code access security for your assembly. The
easiest way to do this is by using .NET tools in Control
Panel/Administrative Tools. Note that you cannot adjust this in your
code. IOPermission.Demand() just check for permission and make things
fail fast if not granted.

Regards,
Thi

Nov 17 '05 #7

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

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
2
by: Wanda | last post by:
Hi all, I have a permission denied error when I tried to copy a file from the local directory to another local directory by using the FSO (FileSystem) Set fso =...
11
by: KK | last post by:
Hello, I am running into a problem for copying files between 2 different servers. I am using the following lines of code to do that, but I get a 'permission denied' error Set fso =...
0
by: Dan | last post by:
We debug a VB.Net App that uses compact framework to a DAP Windows CE.Net device. When I debug I would like to only have the EXE copied down. Right now it copies any referrences as well and...
8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
5
by: Mark | last post by:
Hi all, I am trying to execute a batch file to copy over files from one server to another. The batch file is using robocopy to copy over the files. ============ private void CopyFiles() {// Use...
2
by: Jerad Rose | last post by:
I have a fairly simple C# console app which copies files from a network folder to a local folder. When the app resides on my local C: drive, it runs just fine. However, when the app resides on a...
18
by: mike3 | last post by:
Hi. I have an interesting problem. The C program presented below takes around 12 seconds to copy 128 MB of data on my machine. Yet I know the machine can go faster since a copying done at a...
6
by: Lalit | last post by:
I am new to python. Infact started yesterday and feeling out of place. I need to write a program which would transfer files under one folder structure (there are sub folders) to single folder. Can...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.