I'm trying to go through a directory and put all of the files into a vector of strings. My problem is that the name of the file is stored, but not its location. Because of this, when I go to open the file later in another function, it doesn't recognize it as a file but rather just a string.

Any ideas on how to change this???

Hope this makes sense

You have to store the file name with location of the file. Otherwise there will be no way to access it later. So I'd suggest creating a string which has the location and the file name ie "C:\MyDir\MyFile".

Also what you do mean by "it doesn't recognize it as a file but rather a string" ?

I mean that because it's not linked to a directory, if I try to open the file, it doesn't know where to open it from.

k, so basically what I said before, you need to form the string to contain the directory path and the file name, and then store it.

What do you mean by create a string with both the file name and its location?? Wouldn't it have to be one or the other? or two separate strings?

lets say my location is "C:\MyDirectory" and the file name is "MyFile.txt", you can concatenate the two and store it as "C:\MyDirectory\MyFile.txt", and then do a file open on that.

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.