Dear All
I want to open a plain text file called: ThePlayListFile.m3u. It is located on a HDD of a Kubuntu desktop. In addition, in the future it will be on a MP3 player attached to the Kubuntu or other Kubuntu computer, and the programme will be on the Kubuntu computer. So the path will and can be different each time I try to open the file.
It is a GUI programme. The intention is to use a FileNameEdit set to select only one file. After the file is selected the whole path/filename is written to a global string (m3uPathFile). To test it is captured correct, I output the global variable to the caption of a label, success:
“/home/stephanos/MyFiles-Kingston/Delphi-Lazarus/Programmes/Linux/64/PlayListV40-V2-TimeLimit-Current-RunFromPC/ThePlayListFile.m3u”
Next I want to open that file, and the following do not work:
Memo1.Enabled := True;
m3uContent := ReadFileToString(m3uPathFile); //
Memo1.Lines.Text := m3uContent;
and
Memo1.Enabled := True;
fileContent := TStringList.Create;
fileContent.LoadFromFile(m3uPathFile);
m3uContent := fileContent.Text; fileContent.Free;
Memo1.Lines.Text := m3uContent;
The latter gives me an error message:
"
Unable to open file "/home/stephanos/MyFiles-Kingston/Delphi-Lazarus/Programmes/Linux/64/PlayListV40-V2-TimeLimit-Current-RunFromPC/ThePlayListFile.m3u" No such file or directory. Press OK to ignore and risk data corruption. Press Abort to kill the program.”
With both methods I can substitute the string for an absolute path:
m3uContent := ReadFileToString(‘/home/stephanos/MyFiles-Kingston/Delphi-Lazarus/Programmes/Linux/64/PlayListV40-V2-TimeLimit-Current-RunFromPC/ThePlayListFile.m3u’)
or
fileContent.LoadFromFile(‘/home/stephanos/MyFiles-Kingston/Delphi-Lazarus/Programmes/Linux/64/PlayListV40-V2-TimeLimit-Current-RunFromPC/ThePlayListFile.m3u’)
and it does work
Because the path will change when the mp3 player is plugged into each computer, I have to find the path to the file on each occasion.
I cannot rely on the m3u file being in the same location as the programme because the m3u player does not allow me to execute a Linux programme from the player. So I am confined to this method.
But I cannot use a string containing the path/filename to open the file.
I am using a global variable as I want to use the path part of the string to open an error messages text file which is in the same folder as the m3u file.
I have drawn a blank.