473,668 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get filenames from shared network directory?

Hi All,
The following code works fine in VB.NET (Windows app and Web app projects) when converted to VB.
It also works fine in C#, BUT only in Windows app project. All tested applications contain only this code on loading of the application (form).

Why does it not work in C# Web app project? Could this be a bug? I am using VS.NET 2003 EA

System.IO.Direc toryInfo di = new System.IO.Direc toryInfo("\\\\M yServer\\MyFold er\\MySubFolder 1\\MySubFolder2 \\MySubFolder3\ \MySubFolder4\\ ");
System.IO.FileI nfo[] fi = new System.IO.FileI nfo[500];
fi = di.GetFiles();
foreach (System.IO.File Info f in fi)
{
Response.Write( f.FullName + "<br>");
// Console.WriteLi ne(f.FullName);
}

Goran Djuranovic
Feb 3 '06 #1
4 1927
Hello, Goran!

GD> Why does it not work in C# Web app project? Could this be a bug? I am
GD> using VS.NET 2003 EA

GD> System.IO.Direc toryInfo di = new
GD> System.IO.Direc toryInfo("\\\\M yServer\\MyFold er\\MySubFolder 1\\MySubFol
GD> der2\\MySubFold er3\\MySubFolde r4\\");
GD> System.IO.FileI nfo[] fi = new System.IO.FileI nfo[500];
GD> fi = di.GetFiles();
GD> foreach (System.IO.File Info f in fi)
GD> {
GD> Response.Write( f.FullName + "<br>");
GD> // Console.WriteLi ne(f.FullName);
GD> }

No, it is not a bug, its all about security.

When your code executes in the web app context you work under ASP.NET account, which may not have access to network share.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 3 '06 #2
Hi Vadym,
Thanks for your response.

So, are you saying that security is different in C# than VB?
I am asking this because the same code works on ASP.NET application written
in VB.NET. Read my previous post again.

Goran
"Vadym Stetsyak" <va*****@ukr.ne t> wrote in message
news:uS******** ******@TK2MSFTN GP11.phx.gbl...
Hello, Goran!

GD> Why does it not work in C# Web app project? Could this be a bug? I am
GD> using VS.NET 2003 EA

GD> System.IO.Direc toryInfo di = new
GD>
System.IO.Direc toryInfo("\\\\M yServer\\MyFold er\\MySubFolder 1\\MySubFol
GD> der2\\MySubFold er3\\MySubFolde r4\\");
GD> System.IO.FileI nfo[] fi = new System.IO.FileI nfo[500];
GD> fi = di.GetFiles();
GD> foreach (System.IO.File Info f in fi)
GD> {
GD> Response.Write( f.FullName + "<br>");
GD> // Console.WriteLi ne(f.FullName);
GD> }

No, it is not a bug, its all about security.

When your code executes in the web app context you work under ASP.NET
account, which may not have access to network share.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Feb 3 '06 #3
Hello, Goran!

GD> So, are you saying that security is different in C# than VB?
GD> I am asking this because the same code works on ASP.NET application
GD> written in VB.NET. Read my previous post again.

Can you post VB version of code, and define how the code written in C# is not working, is there any exception being thrown or smth else?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 3 '06 #4

You are running as the ASP.NET account so you need to have permissions
to do that.

Goran Djuranovic wrote:
Hi All,
The following code works fine in VB.NET (Windows app and Web app
projects) when converted to VB.
It also works fine in C#, BUT only in Windows app project. All tested
applications contain only this code on loading of the application (form).

Why does it not work in C# Web app project? Could this be a bug? I am
using VS.NET 2003 EA

System.IO.Direc toryInfo di = new
System.IO.Direc toryInfo("\\\\M yServer\\MyFold er\\MySubFolder 1\\MySubFolder2 \\MySubFolder3\ \MySubFolder4\\ ");
System.IO.FileI nfo[] fi = new System.IO.FileI nfo[500];
fi = di.GetFiles();
foreach (System.IO.File Info f in fi)
{
Response.Write( f.FullName + "<br>");
// Console.WriteLi ne(f.FullName);
}

Goran Djuranovic

Feb 3 '06 #5

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

Similar topics

27
2549
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: Mensaje de error del analizador: We can't load the type 'JULIAN.Global'.
4
9564
by: Goran Djuranovic | last post by:
Hi All, The following code works fine in VB.NET (Windows app and Web app projects) when converted to VB. It also works fine in C#, BUT only in Windows app project. All tested applications contain only this code on loading of the application (form). Why does it not work in C# Web app project? Could this be a bug? I am using VS.NET 2003 EA System.IO.DirectoryInfo di = new...
10
1490
by: Lloyd Dupont | last post by:
I have written a .NET application which does heavy use of interop (through ManagedC++). It works allright. Now someone askedme if it works when installed in a shared directory. So I'm testing, installed the application on a remote computer, in a shared folder and trying to run it from this remote folder. I have SecurityException all over the places, which doesn't surprise me. But how do I fix them?
0
1408
by: ColdCoffee | last post by:
Scenario: My computer: name : PrasComp pass : Pras123 Domain : XYZ Computer I wanna access: Name : AnoComp pass : #Pras
0
8459
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8575
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.