| | |
VC++ Help: convert from System::String to const char*;
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
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:
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:
Any and all help will be appreciated. ps: I have trolled the interwebz looking for an answer and can't find anything helpful.
ex:
C++ Syntax (Toggle Plain Text)
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:
C++ Syntax (Toggle Plain Text)
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.
0
#3 Oct 23rd, 2009
•
•
•
•
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.
Last edited by Tom Gunn; Oct 23rd, 2009 at 1:18 pm.
-Tommy (For Great Justice!) Gunn
•
•
Join Date: Oct 2009
Posts: 52
Reputation:
Solved Threads: 6
0
#4 Oct 23rd, 2009
Last edited by Fbody; Oct 23rd, 2009 at 1:24 pm.
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
0
#5 Oct 23rd, 2009
•
•
•
•
System::Stringis not the same asstd::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.
Last edited by desimator55; Oct 23rd, 2009 at 1:35 pm. Reason: Added information
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
0
#7 Oct 23rd, 2009
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.
Last edited by desimator55; Oct 23rd, 2009 at 1:50 pm.
![]() |
Similar Threads
- string / const char* conversion problem (C++)
- Convert at System::String ^ (C++)
- first cannot conver std::string to const char, now runtime error! (C++)
- How to convert string to const char* in C (C++)
- converting std::string to const chars? (C++)
Other Threads in the C++ Forum
- Previous Thread: booking a ticket for flight
- Next Thread: Need help!
Views: 519 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






