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

Getting the full path of a folder.

I have a class library with a method called getpath(). I want to be able to get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
--
Dotty
Jul 20 '06 #1
4 4032
Take a look at System.IO.Path.GetFullPath()

Andy

Dots wrote:
I have a class library with a method called getpath(). I want to be able to get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
--
Dotty
Jul 20 '06 #2
Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always Web_mycontrol\my_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the web
application you could perhaps pass the path as a command line parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo.coma écrit dans le message de news:
0F**********************************@microsoft.com...
>I have a class library with a method called getpath(). I want to be able to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
--
Dotty

Jul 20 '06 #3
To explain better, there is a path that my web application writes to and I want
to use the same path for my console application to dump files.

The console application is not called by the web application. Actually,
forget about the web application right now.

The path will always be the same
"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
No changes at all.

I just want my console application to use a method in my class library called
getpath() to grab the path and dump files in the my_files_dir folder.

right now I have an app.config file with my console application which is this

<appSettings>
<add key ="ResultFileLocation" value ="/Web_mycontrol" />
</appSettings>

and at the begining of my getpath() method I have this
FileLocation = AppSettings("ResultFileLocation")

Is this clear enough? Any clue?

--
Dotty
"Patrice" wrote:
Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always Web_mycontrol\my_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the web
application you could perhaps pass the path as a command line parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo.coma écrit dans le message de news:
0F**********************************@microsoft.com...
I have a class library with a method called getpath(). I want to be able to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
--
Dotty


Jul 20 '06 #4
If you want to keep a virtual path, you'll need also to know the web site so
that the console app can resolve the physical path (IMO no clear benefit).
It could cause problem in special cases (for example you removed the site
but want to do a last process on those files with your console application,
resolving the path will become impossible once the web site is removed).

My personal preference would be just to put the full path in the application
configuration file (my logic is that this is a console application that
doesn't have to know what a web site is, its job is just to process files
stored at a given filesystem location).

--
Patrice

"Dots" <my*****@yahoo.coma écrit dans le message de news:
C3**********************************@microsoft.com...
To explain better, there is a path that my web application writes to and I
want
to use the same path for my console application to dump files.

The console application is not called by the web application. Actually,
forget about the web application right now.

The path will always be the same
"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
No changes at all.

I just want my console application to use a method in my class library
called
getpath() to grab the path and dump files in the my_files_dir folder.

right now I have an app.config file with my console application which is
this

<appSettings>
<add key ="ResultFileLocation" value ="/Web_mycontrol" />
</appSettings>

and at the begining of my getpath() method I have this
FileLocation = AppSettings("ResultFileLocation")

Is this clear enough? Any clue?

--
Dotty
"Patrice" wrote:
>Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always
Web_mycontrol\my_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the
web
application you could perhaps pass the path as a command line
parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo.coma écrit dans le message de news:
0F**********************************@microsoft.com...
>I have a class library with a method called getpath(). I want to be able
to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to
hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\wwwroot\Web_mycontrol\my_Files_dir \"
--
Dotty



Jul 21 '06 #5

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

Similar topics

2
by: gwen | last post by:
Hi, I have a code to copy/move folders to a specified folder on the root drive - ie c:\stuff However, I also have the folder "stuff" on the root of other partitions as well - ie d:\stuff,...
3
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a...
0
by: Bart Plessers \(artabel\) | last post by:
Hello From a dbase, I extract folder information with an ASP script. The records contain the full path of every folder like: folder\presentatie\project1 folder\details\project2...
3
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
1
by: Craig | last post by:
Hi I was wondering how to get the path that a DLL is running from (from a method within that DLL, e.g. it's own install path))? I have a web app with two modules. I'd like one of them to be able...
2
by: RAB | last post by:
I tested my code on my local computer and it worked fine. When I uploaded it to my webserver at Godaddy.com, I get the following error... Exception Details: System.Data.OleDb.OleDbException:...
0
by: smanisankar | last post by:
hi, the following is the full page code for uploading a file to server. since i got no idea to overwrite the file, i want delete the file if the file is already uploaded. i got the folder name...
4
by: pedestrian via DotNetMonster.com | last post by:
I'm using VB 2005. How to get the full path for "Program Files" folder in Windows, ie. either it is C:\Program Files or D:\Program Files or etc.? How about the full path of "Windows" folder?...
0
by: mathewgk80 | last post by:
Hi all, I uploaded an image (the name of the image is image1) to a folder (the name of the folder is Images) in the solution explorer.The full path of the image is "c:\\Documents and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.