473,587 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying File to Program Directory

My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.

I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.

I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.

I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?

I'm very grateful for the help.
-Dan

Mar 18 '07 #1
9 3920
Hi Dan,

Can you show us some code?

Cor

"pooba53" <po*****@gmail. comschreef in bericht
news:11******** *************@y 66g2000hsf.goog legroups.com...
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.

I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.

I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.

I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?

I'm very grateful for the help.
-Dan

Mar 18 '07 #2
It's been a while since I "played" with Access databases, but I'm wondering
if the database is in use when you try to copy it?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS
"pooba53" <po*****@gmail. comwrote in message
news:11******** *************@y 66g2000hsf.goog legroups.com...
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.

I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.

I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.

I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?

I'm very grateful for the help.
-Dan

Mar 18 '07 #3
"pooba53" <po*****@gmail. comschrieb:
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.

I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.

I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.

I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
With administrator privileges this should work. However, it won't work for
normal users.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 18 '07 #4
On Mar 18, 4:58 am, "<ct>" <carstentATinte gratedsolutions .dkwrote:
It's been a while since I "played" with Access databases, but I'm wondering
if the database is in use when you try to copy it?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"pooba53" <poob...@gmail. comwrote in message

news:11******** *************@y 66g2000hsf.goog legroups.com...
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
I'm very grateful for the help.
-Dan
There are no active transactions taking place and I can take a copy of
the data.mdb file and copy it by hand without any problems.

Mar 18 '07 #5
FileSystem.File Copy(OpenFileDi alog1.FileName, TargetFile)

The .Filename path is correct as well as the TargetFile path when both
are sent to a msgbox() for confirmation.

-Dan

On Mar 18, 1:22 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
Hi Dan,

Can you show us some code?

Cor

"pooba53" <poob...@gmail. comschreef in berichtnews:11* *************** *****@y66g2000h sf.googlegroups .com...
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
I'm very grateful for the help.
-Dan

Mar 18 '07 #6
Guess I need to assume then that it's not a permissions problem.

-Dan

On Mar 18, 8:06 am, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrot e:
"pooba53" <poob...@gmail. comschrieb:
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?

With administrator privileges this should work. However, it won't work for
normal users.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 18 '07 #7
Okay, more information...i t appears the issue *is* with the database
file being used. I changed the name of the file being copied over to
something else and it works.

New question: How do I close the "interactio n" between data.mdb and my
application prior to doing the filecopy? I apologize for not being an
ado.net expert ;-)

After I copy the file, I close the application and have the user
relaunch using the new database.

Thanks!
-Dan

On Mar 18, 4:58 am, "<ct>" <carstentATinte gratedsolutions .dkwrote:
It's been a while since I "played" with Access databases, but I'm wondering
if the database is in use when you try to copy it?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"pooba53" <poob...@gmail. comwrote in message

news:11******** *************@y 66g2000hsf.goog legroups.com...
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
I'm very grateful for the help.
-Dan

Mar 18 '07 #8
Are you disposing of the connection?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS
"pooba53" <po*****@gmail. comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
Okay, more information...i t appears the issue *is* with the database
file being used. I changed the name of the file being copied over to
something else and it works.

New question: How do I close the "interactio n" between data.mdb and my
application prior to doing the filecopy? I apologize for not being an
ado.net expert ;-)

After I copy the file, I close the application and have the user
relaunch using the new database.

Thanks!
-Dan

On Mar 18, 4:58 am, "<ct>" <carstentATinte gratedsolutions .dkwrote:
>It's been a while since I "played" with Access databases, but I'm
wondering
if the database is in use when you try to copy it?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"pooba53" <poob...@gmail. comwrote in message

news:11******* **************@ y66g2000hsf.goo glegroups.com.. .
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
I'm very grateful for the help.
-Dan


Mar 19 '07 #9
Tried two scenarios:

1. Closed db connections in the main form before doing the copy. No
change.

2. First I copied my imported data to the program directory under a
different name while the application is running. I thn close the
application.

When I re-launch my application, and in the formload event, I see if
the import file is present. If it is, I copy it over to the exiting
file name and location:

AppBase = AppDomain.Curre ntDomain.BaseDi rectory & "data.mdb"
ImportFile = AppDomain.Curre ntDomain.BaseDi rectory &
"data_expor t"

If File.Exists(Imp ortFile) Then
Try
FileSystem.File Copy(ImportFile , AppBase)
File.Delete(Imp ortFile)
Catch
MsgBox("import of financial data did not succeed.")
End Try
End If

This all happens before I even establish a db connection. Still a no-
go ;-(

On Mar 19, 12:55 am, "<ct>" <carstentATinte gratedsolutions .dkwrote:
Are you disposing of the connection?

--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"pooba53" <poob...@gmail. comwrote in message

news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
Okay, more information...i t appears the issue *is* with the database
file being used. I changed the name of the file being copied over to
something else and it works.
New question: How do I close the "interactio n" between data.mdb and my
application prior to doing the filecopy? I apologize for not being an
ado.net expert ;-)
After I copy the file, I close the application and have the user
relaunch using the new database.
Thanks!
-Dan
On Mar 18, 4:58 am, "<ct>" <carstentATinte gratedsolutions .dkwrote:
It's been a while since I "played" with Access databases, but I'm
wondering
if the database is in use when you try to copy it?
--
Carsten Thomsen
Senior .NET Solutions Architect / Developer / Author
MCAD/MCSD/MCSE/MCTS"pooba53" <poob...@gmail. comwrote in message
>news:11******* **************@ y66g2000hsf.goo glegroups.com.. .
My VB .NET application (created in VS 2003) resides in c:\Program Files
\Test\ and there's a data.mdb (Access) file within this directory.
I have a feature in my program that allows the user to import a backup
copy of this Access db if they need to.
I'm using the FileCopy method to simply copy over the data.mdb file
within the directory above. However, I get a
"System.Unautho rizedAccessExce ption: Access to the path: c:\Program
Files\Test\data .mdb denied" when the copy is attempted.
I have admin rights to my XP computer and am wondering if this is some
sort of security issue. How does one write to the application
directory?
I'm very grateful for the help.
-Dan

Mar 19 '07 #10

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

Similar topics

22
7415
by: Bryan Rickard | last post by:
I wrote a simple program in VB6 to copy all the files from a directory on a CD-ROM to my hard disk. There are about 10 files, each about 30MB. The program uses Get and Put to get data from the CD into a buffer and then put it into the disk. See code below. It works, but it slows down drastically before it copies all the files. Windows...
5
6047
by: Ian Davies | last post by:
Hello I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your...
5
13696
by: Trowa | last post by:
Hi, I'm trying to use FileSystemWatcher to determine when a new file has been added to a directory. However, after the file has been added, I need to process the file. This results in a problem if the file is large and takes time to copy, as the events appear to get received before the copy is finished. I've tried listening to the...
10
7822
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in 'to.txt' I specify where to copy it - After I read content of 'to.txt' I create one more subfolder named by current date and thats where everything gets...
3
1226
by: Phil Galey | last post by:
In VB.NET, is there any way to copy a directory and all its contents to a new location using io.Directory or io.DirectoryInfo etc. without having to import the Scripting.FileSystemObject? io.Directory and DirectoryInfo only seem to have a Move command, but what about copying?
16
2420
by: NoodNutt | last post by:
G'day ppl Is there a process whereby I can copy the text labels of all the files in a root directory? I recall going back a long way seeing something about it but did not take any notice as I didn't think I would ever use it. TIA Mark
4
15414
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the tables in it automatically? I was hoping to have the tables (the frm files) included in a subdirectory and when required, just create a new schema...
6
1162
by: Barry Flynn | last post by:
In VS2005, I want to write a program which will have some similarity to an existing program. It would be an advantage to start by copying the existing program (into a new directory, and with new names for the forrms etc.) . What is the easiets way to do that? Thanks --
13
10613
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to process the file. The appearance of the command file triggers the device to grab the original file. My problem is I don't want to write the command file...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5394
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2358
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 we have to send another system
1
1454
muto222
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.