Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

[Help Needed] From ASP to ASP.NET(C#)

Posted on 2004-03-30
6
Medium Priority
?
179 Views
Last Modified: 2010-04-15
Dear all,

Need your expertise here. I am converting a ASP code to ASP.NET(C#). I am wondering if anybody have any idea on how to convert the following ASP code ? I am trying to list the folders inside a virtual directory. Thanks a lot in advance.


ASP Code:

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.Mappath("../.."))
strTopFolder = objFolder.Path & "\"
0
Comment
Question by:bhchng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
AdrianJMartin earned 75 total points
ID: 10723317

      string[] dirs = System.IO.Directory.GetDirectories( Server.MapPath(@"..\.." ) ) ;
      string topFolder = dirs[0] + @"\" ;

beware the "..\.." on my system this exits the tree ie no more up dirs and a System.Web.HttpException is thrown.

0
 

Assisted Solution

by:dotnet_programmer
dotnet_programmer earned 75 total points
ID: 10723387
DirectoryInfo currentDirectory;
string strPath;
string strTopFolder;
strPath = @"../..";

currentDirectory = new DirectoryInfo(strPath);
           
if (!currentDirectory.Exists)
{
     throw new ArgumentException("Directory does not exist " + strPath + ".");
}
else
{
     strTopFolder = Path.GetFullPath(currentDirectory.Name) + @"\";
}

0
 

Expert Comment

by:dotnet_programmer
ID: 10723407
make sure to include "using System.IO" in your cs file.
0
 

Expert Comment

by:dotnet_programmer
ID: 10723420
also just in case you are wondering, the @ before the quotes (i.e. @"\") tells the compiler to ignore the break characters like \ in the string. Otherwise you would get an error compiling.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question