Tài liệu C Sharp part13 - Pdf 87

mình mởi đầu một cái ví dụ lấy nội dung một file!
PHP Code:
using System;
using System.IO;
using System.Text;

/*
* Created by SharpDevelop.
* NetDevelop Co., Ltd.
* Author: Tuan Anh Nguyen Ngoc
* Date: 11/21/2006
* Contact Information.
* - Email: [email][email protected][/email]
* - Handheld: +84 905 202 088
*/
namespace Ans.Utilities
{

public class File
{
/// <summary>
/// define string fullpath.
/// </summary>
private string _sFullPath;
/// <summary>
/// Contruction of this class.
/// </summary>
public File() { }
/// <summary>
/// Contruction of this class.
/// </summary>

if (System.IO.File.Exists(this.FullPath))
{
///Create filestream with filemode open and fileaccess read.
FileStream _oFileStream = new FileStream(this.FullPath, FileMode.Open, Fi
leAccess
.Read);
///Create byte array.
Byte[] _oByte = new byte[1024];
///Create UTF8Encoding.
UTF8Encoding _oUTF8Encoding = new UTF8Encoding();
///while filestream read byte > 0.
while (_oFileStream.Read(_oByte, 0, _oByte.Length)>0)
{

_sResult += _oUTF8Encoding.GetString(_oByte);
}
}
else
///throw exception.
throw new Exception("Can not get content! The file can not be found.");
}
///return result.
return _sResult;
}
/// <summary>
/// Get file content.
/// orverload fileContent method.
/// </summary>
/// <param name="_pfullpath">The fullpath string.</param>
/// <returns>return file content as string.</returns>


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status