473,394 Members | 1,706 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.

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.UnauthorizedAccessException: 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 3901
Hi Dan,

Can you show us some code?

Cor

"pooba53" <po*****@gmail.comschreef in bericht
news:11*********************@y66g2000hsf.googlegro ups.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.UnauthorizedAccessException: 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*********************@y66g2000hsf.googlegro ups.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.UnauthorizedAccessException: 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.UnauthorizedAccessException: 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>" <carstentATintegratedsolutions.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.googlegro ups.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.UnauthorizedAccessException: 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.FileCopy(OpenFileDialog1.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*********************@y66g2000hsf.go oglegroups.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.UnauthorizedAccessException: 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.atwrote:
"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.UnauthorizedAccessException: 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...it 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 "interaction" 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>" <carstentATintegratedsolutions.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.googlegro ups.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.UnauthorizedAccessException: 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.googlegr oups.com...
Okay, more information...it 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 "interaction" 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>" <carstentATintegratedsolutions.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.googlegr oups.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.UnauthorizedAccessException: 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.CurrentDomain.BaseDirectory & "data.mdb"
ImportFile = AppDomain.CurrentDomain.BaseDirectory &
"data_export"

If File.Exists(ImportFile) Then
Try
FileSystem.FileCopy(ImportFile, AppBase)
File.Delete(ImportFile)
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>" <carstentATintegratedsolutions.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.googlegr oups.com...
Okay, more information...it 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 "interaction" 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>" <carstentATintegratedsolutions.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.googlegr oups.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.UnauthorizedAccessException: 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
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...
5
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...
5
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...
10
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...
3
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? ...
16
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...
4
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...
6
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...
13
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...
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: 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
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
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.