472,125 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 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 3908
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by gwen | last post: by
3 posts views Thread by Kali K E | last post: by
reply views Thread by Bart Plessers \(artabel\) | last post: by
3 posts views Thread by Bill Brother | last post: by
1 post views Thread by Craig | last post: by
2 posts views Thread by RAB | last post: by
4 posts views Thread by pedestrian via DotNetMonster.com | last post: by
reply views Thread by leo001 | last post: by

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.