0

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

2
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by stilllearning
0

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" ?

0

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.

0

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.

0

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?

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.