I'm using VC++ .net to write a program for searching through files in a directory and then opening them. The only problem I have run into is opening the file. I tried using streamreader but this does not work for opening pdf files. Currently I'm using system ("start //location and name of file");
ex:

system("start c:\\Users\\Member\\Desktop\\filename.pdf");

Now this works great except for the fact that I need for filename to be changed while in my program. I tried passing a string that was gathered earlier in the program into it and I get an error saying that cannot convert parameter 1 from System:: String ^ to const char *
code error:

system("start c:\\Users\\Member\\Desktop\\"+filename+".pdf");

Any and all help will be appreciated. ps: I have trolled the interwebz looking for an answer and can't find anything helpful.

Recommended Answers

All 7 Replies

Are you using the <string> header?

If so, have you tried using filename.c_str() to get the actual string characters rather than the array?

Are you using the <string> header?

System::String is not the same as std::string . The former is the .NET framework's string class that is used in C++/CLI code.

I have trolled the interwebz looking for an answer and can't find anything helpful.

Your question is a Microsoft knowledge base article. It came up as the first hit when searching Google for your thread title.

System::String is not the same as std::string . The former is the .NET framework's string class that is used in C++/CLI code.
...

Oh...

As I'm sure you've guessed, I'm pretty new to C++ (especially VC++).

Thanks for the info.

System::String is not the same as std::string . The former is the .NET framework's string class that is used in C++/CLI code.


Your question is a Microsoft knowledge base article. It came up as the first hit when searching Google for your thread title.

I tried implementing those examples into my code but received varying errors from each. The main error was when trying to #include the header files that they supplied. Each method I fooled around with for an amount of time before I decided to ask here. I thought that the last method was my best hope because it states that it is available for Visual C++ 2008.

The last example can't be compled with the express edition.

commented: Helpful +0

The last example can't be compled with the express edition.

Oh, well then I guess I will have to get a complete version of Visual Studio 2008. So if and when I get this that code will work then? Are there any ways to work around this or do I have to locate the complete version? I have to leave for the weekend so thank you for the help and I'll check as soon as possible for an answer.

I don't know of any workaround, but then I have not done all that much CLR programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.