Issue loading files several folders deep
BlitzMax Forums/BlitzMax Beginners Area/Issue loading files several folders deep
| ||
I don't know why this fails, I am trying to load a file using ReadSteam that is two folders inside the folder that my .bmx and .exe file are. If I put the file in the same folder as my .bmx and .exe it reads fine. ofc I have checked the file paths and so on and they're correct. All Fail Local fileIn:TStream = ReadStream("/folder1/folder2/myfile.txt") Local fileIn:TStream = ReadStream("folder1/folder2/myfile.txt") Local fileIn:TStream = ReadStream("\folder1\folder2/myfile.txt") Local fileIn:TStream = ReadStream("folder1\folder2/myfile.txt") Local fileIn:TStream = ReadStream(CurrentDir()+"\folder1\folder2\myfile.txt") Works Local fileIn:TStream = ReadStream("myfile.txt") I tried using back slashes, removing the fist slash, using currentdir() and manually using the full system path but nothing helps, stumped now?! |
| ||
Hi, try this: Local fileIn:TStream = ReadStream(CurrentDir() + "/folder1/folder2/myfile.txt") -Henri |
| ||
nope |
| ||
Why not use LoadText()? Read the whole file at once. file=LoadText("Incbin::./data/text_"+lang+".txt") And then split it into lines and get your data. For Local line:String=EachIn file.split("~n") |
| ||
Also doesn't work, however I noticed the '.' after the incbin in your path and nowLocal fileIn:TStream = ReadStream("./folder1/folder2/myfile.txt") works. I'll stick to stream unless there are advantages to using LoadText? [EDIT] Well I though it worked but I had the file in the same folder as my .bmx and .exe and for some reason it loads fine if its in there but I'm calling the file from another folder?! This is just bizzare |
| ||
What does it show if you run this:Print CurrentDir() + "/folder1/folder2/myfile.txt"Are you running in Windows ? -Henri |
| ||
@Henri Yes Windows and path looks correct when I print it to console as you advise. But I found the issue, I forget I was load a second file using a value from the first text file but I was omitting the path and just calling the filename. Once I added the path its all fine. A silly little mistake but has stumped me for hours. |