473,403 Members | 2,338 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,403 software developers and data experts.

Access to the path 'xyz' is denied.

1,271 Expert 1GB
I am writing my very first .net program. I'm writing a simple Windows form program that should merge the contents of all the files in a folder into one single file in a different folder.

Every time, no matter what path I use, I am getting
Access to the path 'blahblah' is denied. I have moved the data into my user folder in order to be sure to actually have access. I have run Visual Studio as Administrator, and I have put this in appmanifest
Expand|Select|Wrap|Line Numbers
  1.   <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.IO
  3.  
  4. Public Class Form1
  5.  
  6.  
  7.  
  8.     Private Sub Merge_cmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Merge_cmd.Click
  9.         Dim Directory As New IO.DirectoryInfo(Me.FolderPath_txt.Text)
  10.         Dim allFiles As IO.FileInfo() = Directory.GetFiles("*.*")
  11.         Dim singleFile As IO.FileInfo
  12.  
  13.         Try
  14.             For Each singleFile In allFiles
  15.                 File.AppendAllText(Me.TargetFile_txt.Text, File.ReadAllText(Me.FolderPath_txt.Text))
  16.             Next
  17.         Catch ex As Exception
  18.             Debug.WriteLine("Exception Information: " & vbCrLf & ex.Message)
  19.         Finally
  20.             'Resume Next
  21.         End Try
  22.  
  23.     End Sub
  24. End Class
The input folder (Me.FolderPath_txt.Text) is
c:\users\Jim\Final
The output file (Me.TargetFile_txt.Text) is
c:\users\jim\dictionary.txt

Here is the result from the debug window
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Exception Information:
Access to the path 'c:\users\Jim\Final' is denied.

Help, please.

Thanks,
jim
Jun 17 '11 #1
0 1304

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Carlitos | last post by:
Hi there, I got a web application in vb.net that uploads a .zip file to a subfolder inside the root folder of the web application. c:\Inetpub\wwwroot\MyWebApp\uploaddir Then, a c# library...
1
by: Bruce W...1 | last post by:
Running Windows 2000 Server here. My ASP.NET app reads an XML file (in the virtual root on the local machine) like this just fine: DataSet ds = new DataSet();...
2
by: Alex Levi | last post by:
I'm tring to open a file using FileStream: dim myFile As New FileStream(myPath, FileMode.Open) It works on every file on FAT32 HDD fine. But when I try to open a several files on NTFS drive I...
2
by: Charles Leonard | last post by:
I have a web service running impersonation of a domain account on Windows Server 2003. I need to access a share which the Web Service classes, themselves, appear to be able to create and access. ...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
2
by: hsphuah | last post by:
I had looked a few previous posted newsgroup and tried a few of the suggestions by different users. None of them work. I hope that someone can help on my issue. For your information, my laptop...
3
by: Mike Collins | last post by:
I am getting Access to the path is denied with the following procedure below. I know I'm showing my ignorance here, but in a different procedure, I am writing an xml file to disk using a DataSet...
1
by: Santosh | last post by:
Hii i am writting following code for attaching file to the emails it runs well on the local server but when i run it on domain servert then it gives an error Access to the path is denied. can any...
5
by: Tim Peer | last post by:
I am getting a dreaded Access To Path <fileis denied in a C# program. I tried granting full access to ASPNET (local machine), the user running the program (a domain administrator) and continue to...
1
by: dotnetuser1 | last post by:
hai to every body, when i am uploding the image into the .net application i am getting the following error. "Access to the path 'C:\ident_oct06\UserImages\kat75a.jpg' is denied." please...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.