You see, if you want to make an application that works in all situations you need to make sure it works in all situations. If you don’t find the file you want it is likely that it doesn’t exist at all. At least not where you are looking.
I could show you how to access the desired directory in another way but I think your problem is quite simple. And another way does not guarantee that it will solve the problem.
You’re in :
C:\Users\Lucas\Documents\Visual Studio 2012\Projects\SLN_CAPRO\CAPRO\bin\Debug
when order access:
../arquivos/teste.jpg
means you’re accessing:
C:\Users\Lucas\Documents\Visual Studio 2012\Projects\SLN_CAPRO\CAPRO\bin\arquivos\teste.jpg
which is not what where you say the file is:
C:\Users\Lucas\Documents\Visual Studio 2012\Projects\SLN_CAPRO\CAPRO\arquivos\teste.jpg
Then the correct thing would be to access it through:
../../arquivos/teste.jpg
But you may want to set up a more complex execution environment with ProcessStartInfo
:
var processo = Process.Start(new ProcessStartInfo() {
WorkingDirectory = "../../arquivos",
FileName = "teste.jpg"
});
I put in the Github for future reference.
how are you filling the Combobox with the files? What error do you get when running
Process.Start(...)
?– mateusalxd
about this, it is right he is identifying the value and knows which is the selected file. The error is "File not found." Because the path is not complete(e.g.: C: Files test.jpg) only that I didn’t want it to be like this... I wanted it to be a way inside the solution so it could be done the way I asked the question
– Lucas Vasconcelos
I can almost assure you that the address of the file is wrong even. I don’t see another problem. Although you might think you’re in one directory and you might be in another. Print
Environment.CurrentDirectory
to see if you are where you think you should be, otherwise you have to change or inform where you are. Or use the full path.– Maniero
Yes vc is right at one point the current address is : (C: Users Lucas Documents Visual Studio 2012 Projects SLN_CAPRO CAPRO bin Debug) and what I want would be (C: Users Lucas Documents Visual Studio 2012 Projects SLN_CAPRO CAPRO test files.jpg) there’s some way I can open the file without having to go the whole way?
– Lucas Vasconcelos
Give I’ll try to answer. But that hardly ask you, because you are trying to run an image? :)
– Maniero
The image is just a test, which will run a PDF with some design standards
– Lucas Vasconcelos
Gave in the same :)
– Maniero