Hi,
In a winform application (in C#) I am trying to write to a file with the following:
String filepath = @"C:\Documents and Settings\MyAccount\MyDirectory";
FileStream fsCurrentFile = new FileStream(filepath,FileMode.Append);
StreamWriter sw = new StreamWriter(fsCurrentFile);
But I get the following error message:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the path "C:\Documents and Settings\MyAccount\MyDirectory" is denied.
I don't understand why I get that because I debug on an Administrator acount.
It is written that it may be because the Directory is read-only.
I checked the Directory, it was read-only; I removed the read-only but it comes back
by some magic I don't know about. All my directories seemed to be Read-Only, and I can't change that (when I
do the change, I comes back afterward!).
Any idea what I could do??
Thanks a million!
Jenny
PS: I just installed VS 2003, maybe it is related to that... 8 1569
In article <66**********************************@microsoft.co m>, an*******@discussions.microsoft.com says... In a winform application (in C#) I am trying to write to a file with the following:
String filepath = @"C:\Documents and Settings\MyAccount\MyDirectory"; FileStream fsCurrentFile = new FileStream(filepath,FileMode.Append); StreamWriter sw = new StreamWriter(fsCurrentFile);
But I get the following error message:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll Additional information: Access to the path "C:\Documents and Settings\MyAccount\MyDirectory" is denied.
Are you running the application off a network drive?
--
Patrick Steele
Microsoft .NET MVP http://weblogs.asp.net/psteele
No I don't run the application from a Network drive
Everything is on my machine
I really don't understand what is going on..
I can't remove the Read-Only attributes on my directories
Jenn
In article <37**********************************@microsoft.co m>, an*******@discussions.microsoft.com says... No I don't run the application from a Network drive. Everything is on my machine.
I really don't understand what is going on... I can't remove the Read-Only attributes on my directories.
Are you sure you've got the right path? You can get the "My Documents"
directory for the current user by using:
Environment.GetFolderPath(Environment.SpecialFolde r.Personal)
--
Patrick Steele
Microsoft .NET MVP http://weblogs.asp.net/psteele
I am creating a new file therefore the exact directory is not important
I did several tests on several directories, and none of them worked
I get this "Access Denied" error on all the directories of my system,
even if I create new ones..
thanks for all your help!!
Jenny
In article <AF**********************************@microsoft.co m>, an*******@discussions.microsoft.com says... I am creating a new file therefore the exact directory is not important. I did several tests on several directories, and none of them worked. I get this "Access Denied" error on all the directories of my system, even if I create new ones...
Very odd... The majority of times I see this error when the application
is executed from a network share or a drive mapped to a network share
(i.e. not coming from a local hard drive). If it doesn't come from a
local hard drive, it has different security policy.
--
Patrick Steele
Microsoft .NET MVP http://weblogs.asp.net/psteele
We just had the exact same problem. Our problem is that we forgot to append the filename to the directory. Doh! So don't forget to do the following:
String filename = @"test.txt";
String filepath = @"C:\Documents and Settings\MyAccount\MyDirectory";
filepath = path.Combine(filepath, filename);
FileStream fsCurrentFile = new FileStream(filepath,FileMode.Append);
StreamWriter sw = new StreamWriter(fsCurrentFile);
Good luck
We just had the exact same problem. Our problem is that we forgot to append the filename to the directory. Doh! So don't forget to do the following:
String filename = @"test.txt";
String filepath = @"C:\Documents and Settings\MyAccount\MyDirectory";
filepath = path.Combine(filepath, filename);
FileStream fsCurrentFile = new FileStream(filepath,FileMode.Append);
StreamWriter sw = new StreamWriter(fsCurrentFile);
Good luck
We just had the exact same problem. Our problem is that we forgot to append the filename to the directory. Doh! So don't forget to do the following:
String filename = @"test.txt";
String filepath = @"C:\Documents and Settings\MyAccount\MyDirectory";
filepath = path.Combine(filepath, filename);
FileStream fsCurrentFile = new FileStream(filepath,FileMode.Append);
StreamWriter sw = new StreamWriter(fsCurrentFile);
Good luck This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Edwinah63 |
last post by:
Hi Everyone,
All the very best for 2004!!
i need urgent help with this problem, the users are about to skin me
alive!!
we have an access front end with linked to sql server 2k tables.
...
|
by: Jenny |
last post by:
Need urgent help for an unsolved problem. In our ASP web application,
we creat a Back button and if user click on this button, it execute
history.go(-1) to go back to the previous page. All our...
|
by: Rob |
last post by:
Hi everyone,
I'm having some big JS problems - my function is making my html code
vanish, and I need help!
Here's the code, try it for yourself. You'll notice that when you
click either links...
|
by: zeyais |
last post by:
Here is my HTML:
<style>
..leftcolumn{float:left;width:300px;border: 1px solid #ccc}
..rtcolumn{float:left;width:600px;border: 1px solid #ccc}
</style>
<body>
<div class="leftcolumn"...
|
by: brabster |
last post by:
Hi, this is my first post so please excuse any mistakes!
I'd like to write files using an upload script in my website, but I'm having problems. I don't seem to be able to write a file. Ive set up...
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include...
|
by: kingp |
last post by:
Hi all
I would like to request for a help here.I am working with db2 databases
and currently been assigned a job to migrate from oracle to Db2.I have
been struggling with a problem and being...
|
by: Domini |
last post by:
Hi all, I need urgent help with an xml issue. Let me explain the scenario:
My VB.NET app needs to read an xml (e.g. Sales Orders). This xml contains say 10 sales orders. Next the app needs to split...
|
by: werks |
last post by:
Hello experts. I have 2 vbp (namely Project1.vbp and Project2.vbp) I Group them into 1 Project, my problem is how can the user choose on what project they want to use using VB6?
My initial idea...
|
by: =?Utf-8?B?Y2phbXBz?= |
last post by:
I have HL-DT-ST RW/DVD GCC-4240N. It seems to be a problem though with either
the cd rom drive or the operating system because whatever CD I put in it does
not recognize as a CDR or a CDRW...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |