I've created a program that will process a file in a certain manner. The processing works fine, the problem I'm having is to open files that has a " " (space) in their dir or filename. See I wanted to be able to use my program in a easy manner on files so I set it up in the registry (added a key for my program in HKEY_CLASSES_ROOT\*\shell). It looks something like this "myprogram.exe %1" (I guess the %1 is the current file being clicked on).

My program already retrieves the file to process via argv[1]. This worked fine when I clicked on files in c:\ with no space in their filename. However as soon as there is a space in the dir or in the filename, my program will fail to open the file. I'm using fstream library for the I/O operations on the file. How can I solve this problem?

I solved my own problem. It was as easy as adding "" in the shell key, like this: myprogram.exe "%1", works without any flaws now.

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.