本文整理汇总了C#中File.length方法的典型用法代码示例。如果您正苦于以下问题:C# File.length方法的具体用法?C# File.length怎么用?C# File.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File.length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lengthTest
public void lengthTest()
{
File target = new File(string.Empty); // TODO: Initialize to an appropriate value
long expected = 0; // TODO: Initialize to an appropriate value
long actual;
actual = target.length();
Assert.AreEqual(expected, actual);
target = new File("Length.3");
java.io.FileOutputStream fos = new java.io.FileOutputStream(target);
fos.write("123".getBytes());
fos.flush();
fos.close();
expected = 3;
actual = target.length();
Assert.AreEqual(expected, actual);
}
示例2: onClick
public virtual void onClick(View v)
{
if (v.Equals(mBtnSend))
{
File file = new File(SRC_PATH);
mFileSize = file.length();
Toast.makeTextuniquetempvar.show();
if (SenderServiceBound)
{
try
{
int trId = mSenderService.sendFile(SRC_PATH);
mTransactions.Add((long) trId);
currentTransId = trId;
}
catch (System.ArgumentException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
Toast.makeText(mCtxt, "IllegalArgumentException", Toast.LENGTH_SHORT).show();
}
}
}
else if (v.Equals(mBtnCancel))
{
if (mSenderService != null)
{
try
{
mSenderService.cancelFileTransfer((int) currentTransId);
mTransactions.RemoveAt(currentTransId);
}
catch (System.ArgumentException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
Toast.makeText(mCtxt, "IllegalArgumentException", Toast.LENGTH_SHORT).show();
}
}
else
{
Toast.makeText(mCtxt, "no binding to service", Toast.LENGTH_SHORT).show();
}
}
else if (v.Equals(mBtnCancelAll))
{
if (mSenderService != null)
{
mSenderService.cancelAllTransactions();
mTransactions.Clear();
}
else
{
Toast.makeText(mCtxt, "no binding to service", Toast.LENGTH_SHORT).show();
}
}
else if (v.Equals(mBtnConn))
{
if (mSenderService != null)
{
mSenderService.connect();
}
else
{
Toast.makeText(ApplicationContext, "Service not Bound", Toast.LENGTH_SHORT).show();
}
}
}