Hi all,
I have to create file share network folder,my code is:

Dim fs As New FileStream("\\<machine1>\Sharefolder\file.prm", FileMode.Create)

windows authorization have done before,and i have full control permission on that folder.
with this Code, i get this error :
Logon failure: unknown user name or bad password.
How can I do this ?

10 Years
Discussion Span
Last Post by ericstenson

Hi- You have this posted in ASP.NET, so I am assuming it is a web application.

Let's simplify this a little, because obviously the permissions are giving you some trouble.

I would suggest an easy work-around. Map a network drive to the folder. Let's say the Z: drive. (Right click on the folder in Windows Explorer and click 'Map Network Drive'.)

Try writing a file from the server to the folder using the credentials specified in IIS. If it works, you are in business. YOU MAY NEED TO ADD THE IIS USER TO THE FOLDER.

The change \\machine with Z:\.

Hope it help.

stenson1 at gmail


Hi,Thanx a lot for Your respond.
My project is vb.net Web Site.
Your solution doesn't help,and I've that error yet.


Can you post the exact error you are getting? When it breaks on IE it should show you something along the lines of DOMAIN\IIS_USER is not authorized to access the file.

You need to make sure on the network resource/folder you are trying to access, the user specified on the exception has access. Try granting "Everyone" full control to the folder.

Is the machine on the same domain? Is there even a domain, or is it just a workgroup?

Have you tried impersonating a different user? (Just google it)


I've posted error later ???!!!
Logon failure: unknown user name or bad password.
and Everyone has full control access to this folder.
and all machines are in Workgroup.


make sure in the SHARING SETTINGS (not security settings), that CHANGE FILES is enabled... in SHARING not SECURITY. By default, it is just READ ACCESS.


I've said that before !!!
it doesn't work .
do You yourself test it?


did you look at the shared settings of the folder?

also, AFTER you map the network drive
can you please try just pasting a file through windows explorer into the folder and see if that works?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.