本文整理汇总了C#中System.IO.File.Truncate方法的典型用法代码示例。如果您正苦于以下问题:C# File.Truncate方法的具体用法?C# File.Truncate怎么用?C# File.Truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.File
的用法示例。
在下文中一共展示了File.Truncate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
//.........这里部分代码省略.........
}
catch (IsolatedStorageException e)
{
MoSync.Util.Log(e);
return MoSync.Constants.MA_FERR_GENERIC;
}
return 0;
};
ioctls.maFileSize = delegate(int _file)
{
File file = mFileHandles[_file];
return file.Size();
};
ioctls.maFileAvailableSpace = delegate(int _file)
{
File file = mFileHandles[_file];
return file.AvailableSpace();
};
ioctls.maFileTotalSpace = delegate(int _file)
{
File file = mFileHandles[_file];
return file.TotalSpace();
};
ioctls.maFileDate = delegate(int _file)
{
File file = mFileHandles[_file];
return Util.ToUnixTimeUtc(file.Date().ToFileTime());
};
ioctls.maFileRename = delegate(int _file, int _newName)
{
File file = mFileHandles[_file];
String newName = core.GetDataMemory().ReadStringAtAddress(_newName);
newName = ConvertPath(newName);
if (newName.Contains("\\"))
{
if (newName[0] != '\\')
throw new Exception("Invalid newName");
}
else
{ // add directory of old file.
newName = Path.GetDirectoryName(file.Path) + "\\" + newName;
}
file.Rename(newName);
return 0;
};
ioctls.maFileTruncate = delegate(int _file, int _offset)
{
File file = mFileHandles[_file];
file.Truncate(_offset);
return 0;
};
ioctls.maFileListStart = delegate(int _path, int _filter, int _sorting)
{
// todo: respect _sorting.
String path = core.GetDataMemory().ReadStringAtAddress(_path);
path = ConvertPath(path);
String filter = core.GetDataMemory().ReadStringAtAddress(_filter);
String pattern = path + filter;
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
FileList fl = new FileList();
fl.dirs = isf.GetDirectoryNames(pattern);
fl.files = isf.GetFileNames(pattern);
fl.pos = 0;
mFileListHandles.Add(mNextFileListHandle, fl);
return mNextFileListHandle++;
};
ioctls.maFileListNext = delegate(int _list, int _nameBuf, int _bufSize)
{
FileList fl = mFileListHandles[_list];
String name;
if (fl.pos < fl.dirs.Length)
name = fl.dirs[fl.pos] + "/";
else if (fl.pos < fl.dirs.Length + fl.files.Length)
name = fl.files[fl.pos - fl.dirs.Length];
else
return 0;
if (name.Length >= _bufSize)
return name.Length;
core.GetDataMemory().WriteStringAtAddress(_nameBuf,
name, _bufSize);
fl.pos++;
return name.Length;
};
ioctls.maFileListClose = delegate(int _list)
{
FileList fl = mFileListHandles[_list];
mFileListHandles.Remove(_list);
return 0;
};
}