1

Been searching high and low for this one and can't seem to figure it out.

So I'm making a web application in visual studio using c# project. There is another project in my solution, it's a c project that compiles to dll. I've gotten to the point where I can pass information between the two and it's working right.

In my application, the user uploads a file and it is saved to the file system in an "includes" folder. The dll (compiled from c code I got from an sdk) is supposed to read in that file and decode it. The dll project works fine when I compile it as an exe and send it a file path.

My question is, how can I get the DLL (now in the bin folder) to skip back a directory and grab this file? I've tried just hardcoding the file path into the c code but it doesn't work.

FILE *fp;
bool isWorking = false
if(fp = fopen("../Include/testFile.fit", "r"))
    isWorking = true

I've also tried just writing to a text file from the DLL, hoping to find where it pops out and use that directory as a reference but the c code isn't creating and saving a file at all in that case.

4

1 回答 1

0

The position of the DLL file in the file system is not important. The important part is where the resulting binary is run and what it sees as its current working directory.

If your C# program uses the DLL, the code in the DLL will be run with the same current working directory as the C# program (unless you change it in the code in your DLL).

So, you should try to load your file in the same way, with regards to path, as if you were to load it from your C# program.

于 2012-09-14T09:10:23.760 回答