Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
At present, my source code project is in disk E, this is its path : E:\WindowsApplication1
In this folder has a folder Files, with path : E:\WindowsApplication1\WindowsApplication1\bin\Debug\Files

I have a form with a browse button to choose file, after choose file, it will save into folder Files automatically. My chosen file is in disk C : C:\Images\image.jpg

This is my problem : after choose file, an errors occurs :
Could not find a part of the path 'C:\Images\WindowsApplication1\bin\Debug\Files\image.jpg

How can I set to default path when I chose the file?
Please help me.
Posted
Updated 14-Jun-11 0:05am
v2
Comments
shakil0304003 14-Jun-11 6:51am    
Need your code!

Your code is broken. You need to fix your code. If you posted your code, I'm sure I could have told you exactly what is wrong. As it stands, I suggest stepping through your code in the debugger, and examining the variables you use to build this path, to see your error.
 
Share this answer
 
The file path is wrong, also something wrong in your code. Please always include code in your question so that you can solutions quickly.

OP wrote:
How can I set to default path when I chose the file?

I hope you are using FolderBrowserDialog, use RootFolder property.
Example for FolderBrowserDialog in C#[^]
 
Share this answer
 
Your code is assuming that the current directory never changes. This just isn't the case. You should ALWAYS build fully qualified paths to any files you're going to use. Do NOT use CurrentDirectory or some equivilent to see wha tthe current directory is. If you have to get to files in your .EXE's folder, then get the path to the .EXE first (using Application.StartupPath or an equivilent), then add your path information to that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900