473,385 Members | 1,536 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,385 software developers and data experts.

security permissions for creating a file

Hello,

in a simple console application I try to create a file with some code like:

FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();

I will get an error System.Security.SecurityException

Are there only one way to avoid this and how this can be done?

Thanks and regards
Mark
Nov 17 '05 #1
12 1935
Mark,

You get this exception because you don't have rights to create or open
the file in the directory that it is set in. You need to try and create the
file in a directory that you have rights to, or, if the file exists, check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hello,

in a simple console application I try to create a file with some code
like:

FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();

I will get an error System.Security.SecurityException

Are there only one way to avoid this and how this can be done?

Thanks and regards
Mark

Nov 17 '05 #2
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or open
the file in the directory that it is set in. You need to try and create the file in a directory that you have rights to, or, if the file exists, check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hello,

in a simple console application I try to create a file with some code
like:

FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();

I will get an error System.Security.SecurityException

Are there only one way to avoid this and how this can be done?

Thanks and regards
Mark


Nov 17 '05 #3
Are you sure that the security exception is for opening the file then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be granted
a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and create

the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #4
hi,

post the text of the exception.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and create

the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #5
hi

Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schrieb im Newsbeitrag news:ON**************@TK2MSFTNGP12.phx.gbl...
hi,

post the text of the exception.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and
create the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #6
hi,

what I am trying:

1. I create a file x.cs with notepad nothing more than a main
public static void Main( string[] args )
{
try
{
FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
};
}

2. built it with csc.exe x.cs and got a x.exe
3. executing x.exe on commandline (local dir, no shares, as admin, no
domain, simple way)
4. got exception - I guess .NET told me that this application is not safe
writing files.
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:e2**************@TK2MSFTNGP14.phx.gbl...
Are you sure that the security exception is for opening the file then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be granted a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and
create the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #7
You loading the executable from a network share.
Programs that are loaded from a network are not trusted to access the local
file system, you have to grant "fulltrust" to the the share you are loading
this application from using caspol.exe.

Willy.
"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
hi,

what I am trying:

1. I create a file x.cs with notepad nothing more than a main
public static void Main( string[] args )
{
try
{
FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
};
}

2. built it with csc.exe x.cs and got a x.exe
3. executing x.exe on commandline (local dir, no shares, as admin, no
domain, simple way)
4. got exception - I guess .NET told me that this application is not safe
writing files.
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:e2**************@TK2MSFTNGP14.phx.gbl...
Are you sure that the security exception is for opening the file
then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be

granted
a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hi Nicholas,
>
> I tried a console application and as admin I have no restriction in any
> directory.
>
> regards Mark
>
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb > im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
>> Mark,
>>
>> You get this exception because you don't have rights to create or
>> open
>> the file in the directory that it is set in. You need to try and create > the
>> file in a directory that you have rights to, or, if the file exists,
>> check
>> the rights on the file to make sure that you can open it for writing.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Mark" <Sc********@gmx.net> wrote in message
>> news:dc*************@news.t-online.com...
>> > Hello,
>> >
>> > in a simple console application I try to create a file with some
>> > code
>> > like:
>> >
>> > FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
>> > FileAccess.Write);
>> > StreamWriter sw = new StreamWriter(file);
>> > sw.Write("Hello");
>> > sw.Close();
>> > file.Close();
>> >
>> > I will get an error System.Security.SecurityException
>> >
>> > Are there only one way to avoid this and how this can be done?
>> >
>> > Thanks and regards
>> > Mark
>> >
>> >
>>
>>
>
>



Nov 17 '05 #8
"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
hi,

what I am trying:

1. I create a file x.cs with notepad nothing more than a main <snip> 2. built it with csc.exe x.cs and got a x.exe
3. executing x.exe on commandline (local dir, no shares, as admin, no
domain, simple way)
If you're running the exe from a local hard drive (as opposed to somewhere
on your network), it sounds like you might have modified your CAS policy.
To verify what permissions your executable is being assigned under your
current CAS policy, follow the steps listed in the "How can I test my policy
changes?" section at
http://msdn.microsoft.com/library/en...ecpoladmin.asp.
If your assembly is local, and it's granted anything other than an
unrestricted permission set, your CAS policy has been modified from its
default configuration.

If you are running with modified policy, was it a deliberate change or not?
If it wasn't deliberate, you might want to simply revert to the default
configuration (after backing up your current configuration). If it was
deliberate, then adding a new code group to allow your application to run as
desired might be a better approach.

If your assembly is granted unrestricted permissions under policy, might the
problem stem from use of assembly-level permissions attributes? In
particular, might you be using any attributes with
SecurityAction.RequestOptional?

4. got exception - I guess .NET told me that this application is not safe
writing files.
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:e2**************@TK2MSFTNGP14.phx.gbl...
Are you sure that the security exception is for opening the file
then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be

granted
a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hi Nicholas,
>
> I tried a console application and as admin I have no restriction in any
> directory.
>
> regards Mark
>
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb > im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
>> Mark,
>>
>> You get this exception because you don't have rights to create or
>> open
>> the file in the directory that it is set in. You need to try and create > the
>> file in a directory that you have rights to, or, if the file exists,
>> check
>> the rights on the file to make sure that you can open it for writing.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Mark" <Sc********@gmx.net> wrote in message
>> news:dc*************@news.t-online.com...
>> > Hello,
>> >
>> > in a simple console application I try to create a file with some
>> > code
>> > like:
>> >
>> > FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
>> > FileAccess.Write);
>> > StreamWriter sw = new StreamWriter(file);
>> > sw.Write("Hello");
>> > sw.Close();
>> > file.Close();
>> >
>> > I will get an error System.Security.SecurityException
>> >
>> > Are there only one way to avoid this and how this can be done?
>> >
>> > Thanks and regards
>> > Mark
>> >
>> >
>>
>>
>
>



Nov 17 '05 #9
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OL**************@TK2MSFTNGP14.phx.gbl...
You loading the executable from a network share.
Actually, it sounds like he probably isn't.

Programs that are loaded from a network are not trusted to access the
local file system, you have to grant "fulltrust" to the the share you are
loading this application from using caspol.exe.
Granting full trust in order to allow writing to one file is a wee bit of
overkill, no? <g>


Willy.
"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
hi,

what I am trying:

1. I create a file x.cs with notepad nothing more than a main
public static void Main( string[] args )
{
try
{
FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
};
}

2. built it with csc.exe x.cs and got a x.exe
3. executing x.exe on commandline (local dir, no shares, as admin, no
domain, simple way)
4. got exception - I guess .NET told me that this application is not safe
writing files.
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
schrieb
im Newsbeitrag news:e2**************@TK2MSFTNGP14.phx.gbl...
Are you sure that the security exception is for opening the file
then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be

granted
a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hi Nicholas,
>
> I tried a console application and as admin I have no restriction in
> any
> directory.
>
> regards Mark
>
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>

schrieb
> im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
>> Mark,
>>
>> You get this exception because you don't have rights to create or
>> open
>> the file in the directory that it is set in. You need to try and

create
> the
>> file in a directory that you have rights to, or, if the file exists,
>> check
>> the rights on the file to make sure that you can open it for writing.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>> "Mark" <Sc********@gmx.net> wrote in message
>> news:dc*************@news.t-online.com...
>> > Hello,
>> >
>> > in a simple console application I try to create a file with some
>> > code
>> > like:
>> >
>> > FileStream file = new FileStream("test.txt",
>> > FileMode.OpenOrCreate,
>> > FileAccess.Write);
>> > StreamWriter sw = new StreamWriter(file);
>> > sw.Write("Hello");
>> > sw.Close();
>> > file.Close();
>> >
>> > I will get an error System.Security.SecurityException
>> >
>> > Are there only one way to avoid this and how this can be done?
>> >
>> > Thanks and regards
>> > Mark
>> >
>> >
>>
>>
>
>



Nov 17 '05 #10

"Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
news:uI**************@TK2MSFTNGP15.phx.gbl...
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:OL**************@TK2MSFTNGP14.phx.gbl...
You loading the executable from a network share.
Actually, it sounds like he probably isn't.


Could be, it would not be the first time someone thinks a mapped drive is a
local disk.
Programs that are loaded from a network are not trusted to access the
local file system, you have to grant "fulltrust" to the the share you are
loading this application from using caspol.exe.


Granting full trust in order to allow writing to one file is a wee bit of
overkill, no? <g>


Nicole,
Sure it is overkill, but at least it's a start, because I'm not sure the OP
knows about CAS at all, if he knew about it, he probably figured the
exception was CAS related, which he didn't.
If he knows about CAS, he might have screwed it's local policy settings
somehow when running from a local disk, which I doubt seriously but I
(whish) could be wrong.
Willy.
Nov 17 '05 #11
hi

Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

regards
Mark

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schrieb im Newsbeitrag news:ON**************@TK2MSFTNGP12.phx.gbl...
hi,

post the text of the exception.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and
create the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #12
hi,

what I am trying:

1. I create a file x.cs with notepad nothing more than a main
public static void Main( string[] args )
{
try
{
FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.Write("Hello");
sw.Close();
file.Close();
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
};
}

2. built it with csc.exe x.cs and got a x.exe
3. executing x.exe on commandline (local dir, no shares, as admin, no
domain, simple way)
4. got exception - I guess .NET told me that this application is not safe
writing files.
Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

thanks and regards
Mark
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb
im Newsbeitrag news:e2**************@TK2MSFTNGP14.phx.gbl...
Are you sure that the security exception is for opening the file then?
Where is the application loaded from? Are you running it from a network
share, or the internet? If so, then the application is going to be granted a limited permission set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
Hi Nicholas,

I tried a console application and as admin I have no restriction in any
directory.

regards Mark

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schrieb im Newsbeitrag news:es**************@tk2msftngp13.phx.gbl...
Mark,

You get this exception because you don't have rights to create or
open
the file in the directory that it is set in. You need to try and
create the
file in a directory that you have rights to, or, if the file exists,
check
the rights on the file to make sure that you can open it for writing.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Sc********@gmx.net> wrote in message
news:dc*************@news.t-online.com...
> Hello,
>
> in a simple console application I try to create a file with some code
> like:
>
> FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate,
> FileAccess.Write);
> StreamWriter sw = new StreamWriter(file);
> sw.Write("Hello");
> sw.Close();
> file.Close();
>
> I will get an error System.Security.SecurityException
>
> Are there only one way to avoid this and how this can be done?
>
> Thanks and regards
> Mark
>
>



Nov 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Olaf Baeyens | last post by:
Can someone out there point me to a URL or other reference how to use these security stuff in .NET? I know everything can be found online on the msdn but since I am new to this security stuff, I...
12
by: Angelos Karantzalis | last post by:
Is there a way to set Permissions based on user roles by using some configuration file for my application ? I'm coming from a Java background, where that could very easily be accomplished but...
13
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm...
116
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
16
by: Marina | last post by:
Hi, I am trying to find the minimum security settings to allow a windows control embedded in IE have full trust. If I give the entire Intranet zone full trust, this works. However, this is...
2
by: Budhi Saputra Prasetya | last post by:
Hi, I managed to create a Windows Form Control and put it on my ASP .NET page. I have done the suggestion that is provided by modifying the security settings. From the stack trace, I would...
18
by: Earl Anderson | last post by:
First, I feel somewhat embarrassed and apologetic that this post is lengthy, but in an effort to furnish sufficient information (as opposed to too little information) to you, I wanted to supply all...
0
by: Bill E. | last post by:
I will be creating an application using MS Access as a client to SQL Server 2005. Each user will have the client installed on his/her machine. Some users will be attached to the local network...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.