This is my code.
When i execute this code, it throws "Access to the path "somepath" is denied." - FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write);
-
StreamWriter sw = new StreamWriter(file);
-
try
-
{
-
sw.Write(vendorInfoStr.ToString());
-
}
What is going wrong.
Thanks,
Srinivasan R.
14 16408 PRR 750
Expert 512MB @srinivasanr
What application are you using? if its asp.net then it doesnot have fileIO permission...or if you maynot have permission to create in that folder...
PRR 750
Expert 512MB -
using System.Security.Permissions;
-
-
string filePath = @"C:\Zp\Er.txt";
-
System.IO.FileInfo fname = new System.IO.FileInfo(filePath);
-
-
FileIOPermission permis = new FileIOPermission(FileIOPermissionAccess.AllAccess, fname.DirectoryName);
-
-
bool all = true;
-
try
-
{
-
permis.Demand();
-
permis.PermitOnly();
-
-
}
-
-
catch (System.Security.SecurityException ex)
-
{
-
all = false;
-
}
-
-
if (all)
-
{
-
//do your stuff
-
}
-
I am using only ASP.NET. But this code is working in my testing environment.
But it is not working in my production server.
This is the log file. - 17:00:03 [9] ERROR VendorIntegration - Error while Transformming Vendor:
-
-
System.UnauthorizedAccessException: Access to the path 'some path' is denied.
-
-
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
-
-
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
-
-
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
-
-
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
-
-
at DataAccess.Process.VendorIntegration.TransformSource(IList vendorInfoList)
thnaks for the reply.
I have used the methods Impersonate the IIS authenticated account or user and it is working fine when i call the code through UI.
But i have called that code automatically by using Thread concept.
Now it throws the same error "UnAuthorizedAccess" exception. Access is denied.
What can i do for it?
You will have to give write permission to the folder that you are outputting the text file through the IIS.
@semomaniz
I do not know how to give write permission to the destination folder through IIS. Please direct me.
PRR 750
Expert 512MB @srinivasanr
I am not sure whether this is the right way.. normally for testing i usually do this ... do ask a system admin for the "correct" way.
1. go to properties of the folder you want to give asp.net write rights.
2. Click security->add->advanced ->click on find now...Here you will find list of users... depending on what you have installed on your computer... click asp.net account and add and give permission to it ...
I gave all permissions to all users and it is working when i call that code through UI. But it is not working when i call that same code through automated job by the use of Thread concept.
I mean i call the same code through Thread concept at a specified time.
PRR 750
Expert 512MB @srinivasanr
Within the same application using a thread... shouldn't be a problem... Could you post some code and error message?
Please see my first post...
This is my code - FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write);
-
StreamWriter sw = new StreamWriter(file);
-
try
-
{
-
sw.Write(vendorInfoStr.ToString());
-
-
}
This is my log message - 17:00:03 [9] ERROR VendorIntegration - Error while Transformming Vendor:
-
-
System.UnauthorizedAccessException: Access to the path 'some path' is denied.
-
-
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
-
-
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
-
-
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
-
-
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
-
-
at DataAccess.Process.VendorIntegration.TransformSource(IList vendorInfoList)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: calfdog |
last post by:
Hello,
Does anyone know a workaround for calling fireEvent.
With the latest from Microsoft OS XP2 and Hot fixes to
IE it now gives an "access denied" error in Python when called.
Here is what...
|
by: Steve |
last post by:
Hi,
Yesterday I signed up for another dedicated linux server with the hosting
company I use and I am having problems getting MySQL 4.1.3 working on it.
I've tried just about everything I can...
|
by: Ian |
last post by:
The beginning of my assembly that I am getting the access error from looks
like this.
*********************************
Imports System.EnterpriseServices
Imports System
Imports...
|
by: Fabian von Romberg |
last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000
PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a
report using the webbrowser, I get the following...
|
by: |
last post by:
Hi All,
I have allready tried to ask a similar question , but got no answer until now. In the meantime, I
found, that I cannot understand some thread-settings for the Main() function
.
If I use...
|
by: ASP.Confused |
last post by:
I have an ASP.NET page writtein in VB that uses ADODB. I just had to
force-install MDAC 2.8 after I tried to rollback to 2.6 (my web host uses
this, and I wanted to be compatible with them.) I...
|
by: ASP.Confused |
last post by:
The old message looked a little stale, so I am re-posting it here. Anybody
have any ideas of what I could do?!? The previous responses to this
question are below. If you want to look at the...
|
by: Ron Weldy |
last post by:
I have a test server runinng 2003/IIS 6 with a mixture of asp and asp.net
files. On my workstation I have a share set up to the folder where the web
files reside. I am just doing quick and dirty...
|
by: Shailesh Humbad |
last post by:
I figured out what was causing the "Access is Denied" error when
calling functions from referenced DLLs in my service. I've tried to
be very detailed, so bear with me.
It turns out that...
|
by: Jeremy Ames |
last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |