本文整理汇总了C#中FileReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# FileReader.ReadString方法的具体用法?C# FileReader.ReadString怎么用?C# FileReader.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader.ReadString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tags
/// <summary>
/// Tagses the specified presious.
/// </summary>
/// <param name="files">The files.</param>
/// <returns></returns>
public List<string> Tags(List<string> files )
{
foreach (var file in files)
{
_fileReader = new FileReader(file);
_length = _fileReader.Length();
long currentPosition = 0;
var trigger = string.Empty;
var skip = false;
var inTrigger = false;
while (_length > currentPosition)
{
var s = _fileReader.ReadString(1);
currentPosition++;
if (s == "<")
{
trigger = string.Empty;
skip = false;
inTrigger = true;
}
trigger = trigger + s;
if (s == " ")
{
if (inTrigger)
{
if (!_tags.Contains(trigger))
{
_tags.Add(trigger);
}
trigger = string.Empty;
skip = true;
inTrigger = false;
}
}
if (s == ">")
{
if (!skip)
{
if (inTrigger)
{
if (!_tags.Contains(trigger))
{
_tags.Add(trigger);
}
trigger = string.Empty;
inTrigger = false;
}
}
}
}
}
return _tags;
}
示例2: Main
static void Main(string[] args)
{
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Loopback, 4040);
Socket ss = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
string pathName = "C:/ftp/cs/";
try
{
ss.Bind(localEndPoint);
ss.Listen(10);
while (true)
{
Console.WriteLine("Servidor escuchando por conexiones");
Socket cliente = ss.Accept();
Console.WriteLine("Conexion aceptada " + cliente.LocalEndPoint.ToString());
FileReader sr = new FileReader(cliente);
int f = sr.ReadInt32();
for (int i = 0; i < f; i++)
{
string fileName = sr.ReadString();
Console.WriteLine("\t"+fileName);
sr.ReadFile(Path.Combine(pathName, fileName));
}
Console.WriteLine("Conexion terminada " + cliente.LocalEndPoint.ToString());
cliente.Shutdown(SocketShutdown.Both);
cliente.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
示例3: ReadHeader
private void ReadHeader(FileReader Reader)
{
Type = (IFFChunkTypes)Enum.Parse(typeof(IFFChunkTypes), Reader.ReadString(4).Replace("#", "").Replace("\0", ""));
Size = Reader.ReadUInt32();
ID = Reader.ReadUShort();
Reader.ReadUShort(); //Flags
Reader.ReadBytes(64); //Label
m_Data = Reader.ReadBytes((int)(Size - 76));
if (!Endian.IsBigEndian)
Array.Reverse(m_Data); //Data is Little Endian, so needs to be reversed.
}
示例4: Bounce
/// <summary>
/// Bounces the specified tags.
/// </summary>
/// <param name="tags">The tags.</param>
/// <param name="files">The files.</param>
public void Bounce(List<string> tags, List<string> files)
{
foreach (var file in files)
{
using ( var fileReader = new FileReader(file))
{
_length = fileReader.Length();
var output = string.Empty;
var trigger = string.Empty;
var bounce = false;
var close = false;
_currentPosition = 0;
while (_length > _currentPosition)
{
var s = fileReader.ReadString(1);
_currentPosition++;
if (s == ">")
close = true;
if (s == "<")
{
trigger = string.Empty;
bounce = false;
close = false;
}
if (!close)
{
trigger = trigger + s;
}
if (close)
{
if (s == ">")
{
trigger = trigger + s;
foreach (var tag in tags)
{
if (trigger.Contains(tag))
bounce = true;
}
if (!bounce)
{
output = output + trigger;
}
}
else
{
output = output + s;
}
}
}
fileReader.Close();
using (var fileWriter = new FileWriter())
{
fileWriter.WriteFile(output, file);
}
}
}
}