Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / September 2008

Tip: Looking for answers? Try searching our database.

Application StartupPath

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TAB - 03 Sep 2008 12:29 GMT
Hi

I need to load the same file in both design mode and in run mode.
The problem is that the Application.StartupPath in design mode is the path
to VCSExpress.exe? and in run mode as expected, my program.

Do I need to have a copy in both folders or are there another solution,
or do I have to have the explicit path to my file?

TAB
Paul Schwann - 03 Sep 2008 12:50 GMT
Hi,

I think you are looking for the assembly path, right? For this
purpose, I use

String path =
System.Reflection.Assembly.GetExecutingAssembly().Location;

and it works so far w/o any issues...

Hope that helps,
Paul
TAB - 03 Sep 2008 14:33 GMT
Thanks, but this give me the same error as before.

In designmode VSC# is still looking in
'C:\Users\Anyone\AppData\Local\Microsoft\VCSExpress\9.0\ProjectAssemblies\ng2tm6b901\segments.xml'.
instead of
C:\Users\Anyone\Dokument\Visual Studio
2008\Projects\DotChar\DotChar\bin\Debug\segments.xml
as it does in run mode.

So I need a way of determine the run time path during design without hard
coding the path.

> Hi,
>
[quoted text clipped - 8 lines]
> Hope that helps,
> Paul
RobinS - 04 Sep 2008 06:43 GMT
Is the file added to your solution? If not, add it to your solution and mark
the copy property to "copy always", and the build action to content. Then it
will copy it to the \bin\debug or \bin\results folder when you build, and
thus will be in application.startuppath.

RobinS.
GoldMail.com
-------------------------------

> Thanks, but this give me the same error as before.
>
[quoted text clipped - 20 lines]
>> Hope that helps,
>> Paul
TAB - 04 Sep 2008 08:13 GMT
Thanks for your answer.

The file exists in my debug and release folders and  I have no problem
reading and writing the file when running the program.

But, I need to read the file in design mode as well, as it is a part of a
user control displayed during design. The problem is that in design mode the
Application.StartupPath
shows the path to VCSExpress folder instead of my project folder. This
results in an error when I open the form with the control in designer.
I can't include the file as a resource, as I need to write to it from time
to time.

TAB

> Is the file added to your solution? If not, add it to your solution and
> mark the copy property to "copy always", and the build action to content.
[quoted text clipped - 29 lines]
>>> Hope that helps,
>>> Paul
Jack Jackson - 04 Sep 2008 18:04 GMT
I spent quite a while trying to do exactly what you are doing, and was
never able to find a solution.

>Thanks for your answer.
>
[quoted text clipped - 44 lines]
>>>> Hope that helps,
>>>> Paul
TAB - 04 Sep 2008 19:44 GMT
Apparently nobody seems to know, so my last solution was to use the
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
to store my .xml file.
I don't know if this should be considered a bug or not?
Anyway it's nice to see I'm not alone.

> I spent quite a while trying to do exactly what you are doing, and was
> never able to find a solution.
[quoted text clipped - 50 lines]
>>>>> Hope that helps,
>>>>> Paul
Jeff Gaines - 04 Sep 2008 23:01 GMT
>Apparently nobody seems to know, so my last solution was to use the
>Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
>to store my .xml file.
>I don't know if this should be considered a bug or not?
>Anyway it's nice to see I'm not alone.

I don't know if it's a bug.

I have a note in my Toolbox:

The recommended folder for user settings is:
System.Windows.Forms.Application.UserAppDataPath
for common application settings:
System.Windows.Forms.Application.CommonAppDataPath

This makes sure users can read/write the data in Vista (XP is not so
fussy) so I think your solution is probably best anyway.

Signature

Jeff Gaines Damerham Hampshire UK
You can't tell which way the train went by looking at the tracks

TAB - 06 Sep 2008 08:57 GMT
I checked these out also, but they are hard to find if you would like to
edit or copy the file manually.
I suppose most users know where there documents are located so decided to
use that folder.

>>Apparently nobody seems to know, so my last solution was to use the
>>Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
[quoted text clipped - 13 lines]
> This makes sure users can read/write the data in Vista (XP is not so
> fussy) so I think your solution is probably best anyway.
Jeff Gaines - 06 Sep 2008 09:21 GMT
>I suppose most users know where there documents are located so decided to
>use that folder.

I think we have a new definition of an optimist :-)

Signature

Jeff Gaines Damerham Hampshire UK
You can't tell which way the train went by looking at the tracks

TAB - 06 Sep 2008 16:36 GMT
Well, sombody has to be. :-)

> On 06/09/2008 in message <O6aPxY$DJHA.4492@TK2MSFTNGP05.phx.gbl> TAB
> wrote:
[quoted text clipped - 3 lines]
>
> I think we have a new definition of an optimist :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.