Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Saturday, March 31, 2012

System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."

Does anyone know what I can do about these issues?Try also

graphicOrig.Dispose();

--Daniel
http://staff.newtelligence.com/danielf/

--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image

Hi,

I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".

What can I do about this ?

Actually I found a workaround, but this gives me an error as well...

I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");

After which I can do these steps without any problem

System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);

Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;

Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);

srcImage.Dispose();

The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);

I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."

Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:

string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.F ileName); // fileUpload is
the id of fileupload html control

Zeeshan
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.

graphicOrig.Dispose();
rectOrig.Dispose();

Zeeshan.
http://zishu.blogspot.com

"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
thanks
it worked !

"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> > Hi,
> > I have this question.
> > When I use the FileUpload WebControl to post an Image (= SourceFile) that
> > I
> > want to resize and write to the server, I keep getting this situation.
> > If that SourceFile is located in My Documents (as in "C:\Documents and
> > Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> > a
> > 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> > from
> > "C:\Folder\imgName".
> > What can I do about this ?
> > Actually I found a workaround, but this gives me an error as well...
> > I can save the PostedFile like this
> > PostedFile.SaveAs(imgPath + "DummyName");
> > After which I can do these steps without any problem
> > System.Drawing.Image srcImage =
> > System.Drawing.Image.FromFile(imgPath + DummyName);
> > Graphics graphicOrig = Graphics.FromImage(srcImage);
> > graphicOrig.CompositingQuality =
> > CompositingQuality.HighQuality;
> > graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> > graphicOrig.InterpolationMode =
> > InterpolationMode.HighQualityBicubic;
> > Rectangle rectOrig = new Rectangle();
> > graphicOrig.DrawImage(srcImage, rectOrig);
> > srcImage.Save(NewFileName, ImageFormat.Jpeg);
> > srcImage.Dispose();
> > The final srcImage is perfect, and everything I need but when I want to do
> > this
> > File.Delete(imgPath + dummyName);
> > I get the IOException that File cannot be deleted:
> > "The process cannot access the file 'ImgPAth\dummyName' because it is
> > being
> > used by another process."
> > Does anyone know what I can do about these issues?
>
thanks
it worked !

"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

System.drawing.image

Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile) that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality = CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is being
used by another process."
Does anyone know what I can do about these issues?Try also
graphicOrig.Dispose();
--Daniel
http://staff.newtelligence.com/danielf/
--Original Message--
From: benoit [mailto:benoit@.discussions.microsoft.com]
Posted At: Monday, January 23, 2006 12:21 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: System.drawing.image
Subject: System.drawing.image
Hi,
I have this question.
When I use the FileUpload WebControl to post an Image (= SourceFile)
that I
want to resize and write to the server, I keep getting this situation.
If that SourceFile is located in My Documents (as in "C:\Documents and
Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
getting a
'FileNotFoundException'. That doesn't happen when I get the SourceFile
from
"C:\Folder\imgName".
What can I do about this ?
Actually I found a workaround, but this gives me an error as well...
I can save the PostedFile like this
PostedFile.SaveAs(imgPath + "DummyName");
After which I can do these steps without any problem
System.Drawing.Image srcImage =
System.Drawing.Image.FromFile(imgPath + DummyName);
Graphics graphicOrig = Graphics.FromImage(srcImage);
graphicOrig.CompositingQuality =
CompositingQuality.HighQuality;
graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
graphicOrig.InterpolationMode =
InterpolationMode.HighQualityBicubic;
Rectangle rectOrig = new Rectangle();
graphicOrig.DrawImage(srcImage, rectOrig);
srcImage.Save(NewFileName, ImageFormat.Jpeg);
srcImage.Dispose();
The final srcImage is perfect, and everything I need but when I want to
do
this
File.Delete(imgPath + dummyName);
I get the IOException that File cannot be deleted:
"The process cannot access the file 'ImgPAth\dummyName' because it is
being
used by another process."
Does anyone know what I can do about these issues?
Try getting the actual path of your posted file from System.IO.Path
namespace. You can use it like this:
string FileName =
System.IO.Path.GetFileName(fileUpload.PostedFile.FileName); // fileUpload is
the id of fileupload html control
Zeeshan
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
Sorry forgot to mention. You cannot manipulate an image at client side,
therefore you need to save the image at server in order to resize it. And
for the delete problem, dispose the Graphics and Rectange object that you
have created before deleting the image.
graphicOrig.Dispose();
rectOrig.Dispose();
Zeeshan.
http://zishu.blogspot.com
"benoit" <benoit@.discussions.microsoft.com> wrote in message
news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile) that
> I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep getting
> a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>
thanks
it worked !
"Zeeshan Muhammad" wrote:

> Sorry forgot to mention. You cannot manipulate an image at client side,
> therefore you need to save the image at server in order to resize it. And
> for the delete problem, dispose the Graphics and Rectange object that you
> have created before deleting the image.
> graphicOrig.Dispose();
> rectOrig.Dispose();
> Zeeshan.
> http://zishu.blogspot.com
> "benoit" <benoit@.discussions.microsoft.com> wrote in message
> news:D1309876-A9ED-4EEA-9197-AD5FF42E09F3@.microsoft.com...
>
>
thanks
it worked !
"Daniel Fisher(lennybacon)" wrote:

> Try also
> graphicOrig.Dispose();
>
> --Daniel
> http://staff.newtelligence.com/danielf/
>
>
> --Original Message--
> From: benoit [mailto:benoit@.discussions.microsoft.com]
> Posted At: Monday, January 23, 2006 12:21 PM
> Posted To: microsoft.public.dotnet.framework.aspnet
> Conversation: System.drawing.image
> Subject: System.drawing.image
> Hi,
> I have this question.
> When I use the FileUpload WebControl to post an Image (= SourceFile)
> that I
> want to resize and write to the server, I keep getting this situation.
> If that SourceFile is located in My Documents (as in "C:\Documents and
> Settings\29\Mijn documenten\SubFolderFolder\ImgName.jpg"), I keep
> getting a
> 'FileNotFoundException'. That doesn't happen when I get the SourceFile
> from
> "C:\Folder\imgName".
> What can I do about this ?
> Actually I found a workaround, but this gives me an error as well...
> I can save the PostedFile like this
> PostedFile.SaveAs(imgPath + "DummyName");
> After which I can do these steps without any problem
> System.Drawing.Image srcImage =
> System.Drawing.Image.FromFile(imgPath + DummyName);
> Graphics graphicOrig = Graphics.FromImage(srcImage);
> graphicOrig.CompositingQuality =
> CompositingQuality.HighQuality;
> graphicOrig.SmoothingMode = SmoothingMode.AntiAlias;
> graphicOrig.InterpolationMode =
> InterpolationMode.HighQualityBicubic;
> Rectangle rectOrig = new Rectangle();
> graphicOrig.DrawImage(srcImage, rectOrig);
> srcImage.Save(NewFileName, ImageFormat.Jpeg);
> srcImage.Dispose();
> The final srcImage is perfect, and everything I need but when I want to
> do
> this
> File.Delete(imgPath + dummyName);
> I get the IOException that File cannot be deleted:
> "The process cannot access the file 'ImgPAth\dummyName' because it is
> being
> used by another process."
> Does anyone know what I can do about these issues?
>

Wednesday, March 28, 2012

system.Io function

hi, i want to know whether a file exists are not in a
particular directory.

how to write a function for it in asp.net using vbFile.Exists(path)

HTH

Thanks,

sswalia
MCAD, MCSD, OCA

"rahim" <rahim786@.rediffmail.com> wrote in message
news:059d01c3c523$20c4c700$a601280a@.phx.gbl...
> hi, i want to know whether a file exists are not in a
> particular directory.
> how to write a function for it in asp.net using vb
If System.IO.File.Exists("C:\somefile.txt") then
'it exists
End If

--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz

"rahim" <rahim786@.rediffmail.com> wrote in message
news:059d01c3c523$20c4c700$a601280a@.phx.gbl...
> hi, i want to know whether a file exists are not in a
> particular directory.
> how to write a function for it in asp.net using vb

System.IO.StreamWriter -- Access to path is denied

Hi, I am trying to use the System.IO.StreamWriter to write to a file, and am getting an error that I have to set permissions for doing this in IIS -- I don't remember how to do this. Does anyone know how?

(Win XP Pro)


System.IO.StreamWriter writer = new System.IO.StreamWriter(@dotnet.itags.org."C:\NetApplicationTest",true);
Hi, u need to add aspNet User to the folder u trying to accessing and give the account have the permission to write/read it in the folder or file.

If u cant see any security tab on ur folder option, do tis below in any folder:
Tools>Folder Options>View>uncheck this "use simple file sharing(Recommended)"

then go to ur file's folder , note: folder
right click then properties> Security>Add > Advance> Find now>
Then u select ASPNET and add it, and set ASPNET to full control.

Hope tis help
life's Ng
beauty, thanks very much! -- I guess that I should study some XP Admin stuff... thanks 'gain ..

Monday, March 26, 2012

System.Net.Mail SMTP Pickup Dir

Hi,

I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:

<mailSettings>
<smtp>
<network

host="localhost"
port="25"
/
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.

Thank you,
MichaelFYI: I found the answer in case anyone wonders about this. Make sure
the AppPool for the IIS web site is running as IWAM_machinename and
that the \Pickup windows share allows IWAM_machinename (using same
username/password on remote machine) write access in addition to the
NTFS write for that subdirectory is allowed.

mpaine@.htxml.com wrote:

Quote:

Originally Posted by

Hi,
>
>
I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:
>
<mailSettings>
<smtp>
<network
>
host="localhost"
port="25"
/>
>
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings>
>
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.
>
>
Thank you,
Michael

Tuesday, March 13, 2012

System.security.securityException: Permission denied in ASP.NET

Hi Friends,

I have to write into an Excel file through my web application. I wrote a program in VB6 which executes the tasks I need to do on the Excel file, and saved it as a .dll. This .dll was than added into the reference of the web application and it was also registered using regsvr32. When I execute this form then I get the following error:

System.security.securityException: Permission denied.

But, when I create the same form as a Windows application, add the reference & register .dll, then the code gets executed and we are able to make the required changes in the excel file.

Plz help me solve this problem.

Thanks,
JavvymDefinitely a permissions error,

Using windows explorer navigate to the folder where your excel file is stored right click the folder choose properies
Select the Security Tab
Add in Authenticated Users, if that doesn't work add the Everyone group
Try running the code again - should work :wave:

Cheers Al
Hi,

This solution doesn't solve the problem. Is there any other solution that you can give me?

Thanks,
Javvym
First thing; I forgot to say to give the groups write Permissions, if you didn't do that then try the below

Remove the Everyone, and Authenticated Users unless they were already there. If they were already there then remove the write permissions.

On the security tab for the folder in question add in the ASPNet account give the user write permissions

W2K - select the machine name from the top dropdown list, then pick ASPNet from the list
XP - In the "Enter the Object names..." box enter the following [your machine name]\aspnet click check names

Once you've got the account click ok - give the ASPNet account write permissions.

Click Apply/Ok and try again

With a bit of luck you'll have won.

Cheers Al

System.Security.SecurityException: Requested registry access is not allowed.

I keep getting this error when my asp.net application tries to write into
the registry
System.Security.SecurityException: Requested registry access is not allowed.
I followed the following article and I still get the error:
http://support.microsoft.com/defaul...kb;en-us;329291
Any suggestions?
ThanksWhen you say write to the registry, do you mean using the EventLog? Or do
you mean explicitly writing to the registry? The account that your ASP.NET
code is running as needs the rights to do whatever you're trying to do. Unde
r
IIS5 it's the local ASPNET account. Under IIS6 it's the local Network Servic
e
account.
-Brock
DevelopMentor
http://staff.develop.com/ballen

> I keep getting this error when my asp.net application tries to write
> into
> the registry
> System.Security.SecurityException: Requested registry access is not
> allowed.
> I followed the following article and I still get the error:
> http://support.microsoft.com/defaul...kb;en-us;329291
> Any suggestions?
> Thanks
>
Actually the problem was that I did not creat the Installet class properly
so Gacutil was unable to create the right permissions for my ASPNET user.
Thanks for your help
"Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
news:763197632520356933089056@.msnews.microsoft.com...
> When you say write to the registry, do you mean using the EventLog? Or do
> you mean explicitly writing to the registry? The account that your ASP.NET
> code is running as needs the rights to do whatever you're trying to do.
> Under IIS5 it's the local ASPNET account. Under IIS6 it's the local
> Network Service account.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>

System.Security.SecurityException: Requested registry access is not allowed.

I keep getting this error when my asp.net application tries to write into
the registry
System.Security.SecurityException: Requested registry access is not allowed.

I followed the following article and I still get the error:
http://support.microsoft.com/defaul...kb;en-us;329291

Any suggestions?

ThanksWhen you say write to the registry, do you mean using the EventLog? Or do
you mean explicitly writing to the registry? The account that your ASP.NET
code is running as needs the rights to do whatever you're trying to do. Under
IIS5 it's the local ASPNET account. Under IIS6 it's the local Network Service
account.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I keep getting this error when my asp.net application tries to write
> into
> the registry
> System.Security.SecurityException: Requested registry access is not
> allowed.
> I followed the following article and I still get the error:
> http://support.microsoft.com/defaul...kb;en-us;329291
> Any suggestions?
> Thanks
Actually the problem was that I did not creat the Installet class properly
so Gacutil was unable to create the right permissions for my ASPNET user.

Thanks for your help
"Brock Allen" <ballen@.NOSPAMdevelop.com> wrote in message
news:763197632520356933089056@.msnews.microsoft.com ...
> When you say write to the registry, do you mean using the EventLog? Or do
> you mean explicitly writing to the registry? The account that your ASP.NET
> code is running as needs the rights to do whatever you're trying to do.
> Under IIS5 it's the local ASPNET account. Under IIS6 it's the local
> Network Service account.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>> I keep getting this error when my asp.net application tries to write
>> into
>> the registry
>> System.Security.SecurityException: Requested registry access is not
>> allowed.
>> I followed the following article and I still get the error:
>> http://support.microsoft.com/defaul...kb;en-us;329291
>>
>> Any suggestions?
>>
>> Thanks
>>