delphixe5android文件定位问题

delphixe5android文件定位问题,android,delphi,delphi-xe5,file-location,Android,Delphi,Delphi Xe5,File Location,我无法从电脑中查找并打开手机上存储的文件。 尽管有很好的解决方案,我还是无法让它发挥作用。 我在运行HTC轰动Z710e 下面是我试图运行的代码: function GetSDCardPath: string; var MusicPathLength: integer; MusicPath, SDCardPath: string; begin MusicPath:=System.IOUtils.TPath.GetSharedMusicPath; MusicPathLength:=Le

我无法从电脑中查找并打开手机上存储的文件。 尽管有很好的解决方案,我还是无法让它发挥作用。 我在运行HTC轰动Z710e

下面是我试图运行的代码:

function GetSDCardPath: string;
var MusicPathLength: integer;
    MusicPath, SDCardPath: string;
begin
 MusicPath:=System.IOUtils.TPath.GetSharedMusicPath;
 MusicPathLength:=Length(MusicPath);
 SDCardPath:=Copy(MusicPath, 0, MusicPathLength-5);
 Result:=SDCardPath;
end;

procedure TForm3.Button1Click(Sender: TObject);
var sr:TSearchRec;
begin
  CardPath:=TPath.Combine(GetSDCardPath,'*.*');

  if (FindFirst(CardPath,faNormal,sr)=0) then
  begin
    repeat
      Memo1.Lines.Add(sr.Name);
    until FindNext(sr)<>0;
    FindClose(sr);
  end;
end;
函数GetSDCardPath:string;
var MusicPathLength:整数;
MusicPath,SDCardPath:字符串;
开始
MusicPath:=System.IOUtils.TPath.GetSharedMusicPath;
MusicPath长度:=长度(MusicPath);
SDCardPath:=复制(MusicPath,0,MusicPath长度-5);
结果:=SDCardPath;
结束;
程序TForm3.按钮1单击(发件人:ToObject);
var sr:TSearchRec;
开始
CardPath:=TPath.Combine(GetSDCardPath,*.*');
如果(FindFirst(CardPath,faNormal,sr)=0),则
开始
重复
备忘录1.行。添加(高级名称);
直到FindNext(sr)0;
FindClose(sr);
结束;
结束;
我用下面的代码做了第二次测试,我显然可以在文件列表中显示文件名时存储文件,但它似乎没有存储在SD卡上,至少没有显示为我的pc上的外部驱动器F:的文件。TPath.GetDocumentsPath应该指向SD卡,不是吗

procedure TForm3.Button1Click(Sender: TObject);
var sr:TSearchRec;
begin
  CardPath:=TPath.Combine(TPath.GetDocumentsPath,'*.*');
  Memo1.Lines.Add(CardPath);

  if (FindFirst(CardPath,faAnyFile,sr)=0) then
  begin
    repeat
      Memo1.Lines.Add(sr.Name);
    until FindNext(sr)<>0;
    FindClose(sr);
  end;
end;

procedure TForm3.WriteClick(Sender: TObject);
var
  s: string;
  F:TextFile;
begin
  Memo1.Lines.Clear;
  s := TPath.Combine(TPath.GetDocumentsPath,'file2.txt');
  AssignFile(F,s);
  ReWrite(F);
  Writeln(F,'Test');
  CloseFile(F);
end;
procedure TForm3.按钮1点击(发送方:TObject);
var sr:TSearchRec;
开始
CardPath:=TPath.Combine(TPath.GetDocumentsPath,*.');
备忘录1.行。添加(CardPath);
如果(FindFirst(CardPath,faAnyFile,sr)=0),则
开始
重复
备忘录1.行。添加(高级名称);
直到FindNext(sr)0;
FindClose(sr);
结束;
结束;
程序TForm3.WriteClick(发送方:TObject);
变量
s:字符串;
F:文本文件;
开始
备忘录1.线条清晰;
s:=TPath.Combine(TPath.GetDocumentsPath,'file2.txt');
转让文件(F,s);
重写(F);
Writeln(F,'Test');
关闭文件(F);
结束;
首先,我单击“写入”按钮写入文件,然后通过单击按钮1列出目录中的文件。 卡片路径为/data/data/com.embarcadero.TestApp2/files/。
我有一个安卓/data/com.embarcadero.TestApp2/files/文件夹,可以从我的电脑上看到,但没有文件。文件是否存储在我的设备内部?

我终于找到了解决方法。 通过使用TPath.GetSharedDocumentsPath,如果保存时设备未连接为驱动器,我可以在pc上看到应用程序保存的文件(如所述)。
E.i.使用应用程序时,电脑不能同时将SD卡用作驱动器。

我忘了提到从电脑上看到的目录结构和从不同的TPath.GetPath字符串中读取的内容差异太大,以至于我无法确定文件的位置。根据你的电脑,确切的路径是什么?您调用了一个函数
GetSDCardPath
,但在那里您只使用了
GetSharedMusicPath
,它可能不在可移动sd卡上。您在设备上看到的确切路径是什么?你忘了告诉我。可移动sd卡上的文件是否与您的电脑一致?添加了另一个测试代码。/data/data/。。。。。是内存。Android/data/data/。。。。是外部存储器,可位于设备中或可移动sd卡上。您的pc/Eclipse无法看到内部内存。我没有使用Eclipse。我只是作为外置驱动器浏览我的设备。要使用什么路径才能使我的电脑和我的应用程序都可以访问同一文件夹?