如何检查文件是否存在于unity android中? [英] How to check a file exist or not in unity android?
本文介绍了如何检查文件是否存在于unity android中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在已知路径中找到文件,如果它已在android中预先存在,则用它触发一个事件(启用/禁用画布).这是我使用的示例-
I want to find the file in the path known and if it is pre-existing in android then trigger an event(enable/disable canvas) with it. Here is an example I used -
public void FileChk(){
string filePath = "file://" + Application.temporaryCachePath + "/" + "folder23" + "/" + fileName;
if (!fileName.Exists)
{
//event
}
else
{
//event
}
}
我在这里做错什么,以及当文件存在时如何触发此事件.
what am I doing wrong here and how do I get this event to trigger when the file exists.
推荐答案
您可以使用System.IO
命名空间.
public void FileChk()
{
string filePath = "file://" + Application.temporaryCachePath + "/" + "folder23" + "/" + fileName;
if (System.IO.File.Exists(filePath))
{
// The file exists -> run event
}
else
{
// The file does not exist -> run event
}
}
方法bool System.IO.File.Exists(string fileName)
返回一个值,该值指示文件是否存在.
The method bool System.IO.File.Exists(string fileName)
returns a value indicating if the file exists or not.
这篇关于如何检查文件是否存在于unity android中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文