本文整理汇总了C#中System.IO.FileStream.Unlock方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.Unlock方法的具体用法?C# FileStream.Unlock怎么用?C# FileStream.Unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileStream
的用法示例。
在下文中一共展示了FileStream.Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendGzippedFile
private void SendGzippedFile(long length, FileStream f, long offset)
{
SendUnknownResponseHeader("Content-Encoding", "gzip");
using (MemoryStream ms = new MemoryStream())
{
using (GZipStream gzip = new GZipStream(ms, CompressionMode.Compress))
{
f.Lock(offset, length);
f.Seek(offset, SeekOrigin.Begin);
const int readBuffLength = 4096;
byte[] buffer = new byte[readBuffLength];
int readed;
while ((readed = f.Read(buffer, 0, readBuffLength)) != 0)
{
gzip.Write(buffer, 0, readed);
}
f.Unlock(offset, length);
//Write some empty block
byte[] rn = Encoding.UTF8.GetBytes(Environment.NewLine);
for (int i = 0; i < 3; i++)
{
gzip.Write(rn, 0, rn.Length);
}
gzip.Flush();
ms.Seek(0, SeekOrigin.Begin);
#if (ETAG)
FileInfo finfo = new FileInfo(f.Name);
string etag = string.Format("\"{0}.{1}\"", finfo.LastWriteTimeUtc.ToFileTimeUtc(), ms.Length);
SendUnknownResponseHeader("Etag", etag);
#endif
SendCalculatedContentLength(ms.Length);
SendResponseFromMemoryInternal(ms.GetBuffer(), (int)ms.Length);
}
}
}
示例2: Unlock_Disposed
public void Unlock_Disposed ()
{
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
DeleteFile (path);
FileStream stream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.Write);
stream.Close ();
stream.Unlock (0,1);
}
示例3: ProcessFilePack
/// <summary>
/// Process a file pack.
/// </summary>
/// <param name="FileName">The name of the file.</param>
/// <param name="FileID">The ID of the file.</param>
/// <param name="StartPoint">The star point of the file pack.</param>
/// <param name="PackID">The ID of the binary data.</param>
/// <param name="Binary">The binary data.</param>
/// <param name="SenderPeer">The sender peer object.</param>
public static void ProcessFilePack(string FileName, string FileID, int StartPoint, string PackID, byte[] Binary, Objects.Peer SenderPeer)
{
Objects.Download download = Downloader.SearchDownload(FileName, FileID);
// control if exist this download and if it is actived
if (download != null && download.Active == true)
{
// control that the binaryPack isn't damaged
SHA1 sha1 = new SHA1CryptoServiceProvider();
if (PackID == BitConverter.ToString(sha1.ComputeHash(Binary)).Replace("-", ""))
{
#region Write to the file
while (true)
{
try
{
// open ( or create ) the file ( in temp-directory )
FileStream fs = new FileStream((Global.TempDirectory + @"\" + FileName), FileMode.OpenOrCreate);
// lock the access to file
fs.Lock(StartPoint, 16384);
// set the start-point
fs.Seek(StartPoint, SeekOrigin.Begin);
int count = 16384;
if((download.Size - StartPoint) < 16384)
{
count = ((int)download.Size - StartPoint);
}
// write the filePack in the file ( temp )
fs.Write(Binary, 0, count);
// unlock the access to file
fs.Unlock(StartPoint, 16384);
fs.Close();
// log the file pack
Downloader.LogFilePack(download, StartPoint, SenderPeer, Downloader.Status_FilePack.Written);
break;
}
catch (IOException) // the file is already locked
{
Thread.Sleep(1);
}
catch (Exception ex) // other problem
{
Utilities.Log.Write("Downloader.cs: error to write in a file: \n" + ex.Message, Utilities.Log.LogCategory.Error);
break;
}
}
#endregion
}
else
{
// log
// communicate to Downloader that the FilePack is damaged
Downloader.LogFilePack(download, StartPoint, SenderPeer, Downloader.Status_FilePack.Damaged);
}
}
}
示例4: UnlockFile
public int UnlockFile(String filename, long offset, long length, DokanFileInfo info)
{
string path = GetPath(filename);
try
{
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
fs.Unlock(offset, length);
fs.Close();
}
catch (Exception e)
{
Console.Error.WriteLine("SetEndOfFile exception: {0}", e.Message);
return -DokanNet.DOKAN_ERROR;
}
return DokanNet.DOKAN_SUCCESS;
}
示例5: UnlockDataStore
private void UnlockDataStore(FileStream fs)
{
fs.Unlock(0, fs.Length);
}
示例6: Save
/// <summary>
/// 写数据
/// </summary>
/// <param name="writer">FileStream对象</param>
/// <param name="data">数据</param>
/// <returns>true-成功;false-失败</returns>
private bool Save(FileStream writer, string data)
{
if (writer == null || writer.Equals(null))
return false;
byte[] b = null;
long len = 0;
b = Utf8.GetBytes(data);
len = writer.Length;
try
{
writer.Lock(0, len);
writer.Seek(0, SeekOrigin.End);
writer.Write(b, 0, b.Length);
writer.Unlock(0, len);
writer.Flush();
}
catch (IOException e)
{
throw e;
}
catch (Exception Ex)
{
throw Ex;
}
finally
{
try
{
writer.Close();
}
catch (Exception Ex)
{
throw Ex;
}
}
return true;
}
示例7: ReadFromFile
// === PUBLIC METHODS ===
public bool ReadFromFile(String fileName)
{
bool result = true;
SPCHeader header = new SPCHeader();
SPCExTags footer = new SPCExTags();
FResetData();
header.Reset();
footer.Reset();
FileStream fs = null;
BinaryReader source = null;
try
{
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
fs.Lock(0,fs.Length);
source = new BinaryReader(fs);
if ( !readHeader(ref source, ref header) ) throw new Exception("Not a PSF file");
// Reads the header tag
if (SPCHeader.TAG_IN_HEADER == header.TagInHeader)
{
source.BaseStream.Seek(REGISTERS_LENGTH,SeekOrigin.Current);
readHeaderTags(ref source);
}
// Reads extended tag
if (fs.Length > SPC_RAW_LENGTH)
{
source.BaseStream.Seek(SPC_RAW_LENGTH,SeekOrigin.Begin);
readExtendedData(ref source, ref footer);
if (footer.Items.ContainsKey(XID6_ARTIST)) FArtist = (String)((ExtendedItem)footer.Items[XID6_ARTIST]).Data;
if (footer.Items.ContainsKey(XID6_CMNTS)) FComment = (String)((ExtendedItem)footer.Items[XID6_CMNTS]).Data;
if (footer.Items.ContainsKey(XID6_SONG)) FTitle = (String)((ExtendedItem)footer.Items[XID6_SONG]).Data;
if (footer.Items.ContainsKey(XID6_COPY)) FYear = ((ExtendedItem)footer.Items[XID6_COPY]).Length.ToString();
if (footer.Items.ContainsKey(XID6_TRACK)) FTrack = ((ExtendedItem)footer.Items[XID6_TRACK]).Length >> 8;
if (footer.Items.ContainsKey(XID6_OST)) FAlbum = (String)((ExtendedItem)footer.Items[XID6_OST]).Data;
if (("" == FAlbum) && (footer.Items.ContainsKey(XID6_GAME))) FAlbum = (String)((ExtendedItem)footer.Items[XID6_GAME]).Data;
long ticks = 0;
if (footer.Items.ContainsKey(XID6_LOOP)) ticks += Math.Min(XID6_MAXTICKS, (int)((ExtendedItem)footer.Items[XID6_LOOP]).Data);
if (footer.Items.ContainsKey(XID6_LOOPX)) ticks = ticks * Math.Min(XID6_MAXLOOP, (int)((ExtendedItem)footer.Items[XID6_LOOPX]).Length );
if (footer.Items.ContainsKey(XID6_INTRO)) ticks += Math.Min(XID6_MAXTICKS, (int)((ExtendedItem)footer.Items[XID6_INTRO]).Data);
if (footer.Items.ContainsKey(XID6_END)) ticks += Math.Min(XID6_MAXTICKS, (int)((ExtendedItem)footer.Items[XID6_END]).Data);
if (ticks > 0)
FDuration = Math.Round( (double)ticks / XID6_TICKSSEC );
}
}
catch (Exception e)
{
System.Console.WriteLine(e.StackTrace);
//LogDelegator.GetLogDelegate()(Log.LV_ERROR, e.Message);
result = false;
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
fs.Close();
}
return result;
}
示例8: GetInfo
// ---------------------------------------------------------------------------
private bool GetInfo(String FileName, ref FileInfo Info)
{
FileStream fs = null;
BinaryReader Source = null;
// Get info from file
bool result = false;
try
{
// Set read-access and open file
fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
fs.Lock(0,fs.Length);
Source = new BinaryReader(fs);
Info.FileSize = (int)fs.Length;
Info.ID3v2Size = GetID3v2Size(Source);
Source.BaseStream.Seek(Info.ID3v2Size, SeekOrigin.Begin);
Info.FPage.ID = Source.ReadChars(4);
Info.FPage.StreamVersion = Source.ReadByte();
Info.FPage.TypeFlag = Source.ReadByte();
Info.FPage.AbsolutePosition = Source.ReadInt64();
Info.FPage.Serial = Source.ReadInt32();
Info.FPage.PageNumber = Source.ReadInt32();
Info.FPage.Checksum = Source.ReadInt32();
Info.FPage.Segments = Source.ReadByte();
Info.FPage.LacingValues = Source.ReadBytes(0xFF);
if ( Utils.StringEqualsArr(OGG_PAGE_ID,Info.FPage.ID) )
{
Source.BaseStream.Seek(Info.ID3v2Size + Info.FPage.Segments + 27, SeekOrigin.Begin);
// Read Vorbis parameter header
//Source.Read(Info.Parameters, 30);
Info.Parameters.ID = Source.ReadChars(7);
Info.Parameters.BitstreamVersion = Source.ReadBytes(4);
Info.Parameters.ChannelMode = Source.ReadByte();
Info.Parameters.SampleRate = Source.ReadInt32();
Info.Parameters.BitRateMaximal = Source.ReadInt32();
Info.Parameters.BitRateNominal = Source.ReadInt32();
Info.Parameters.BitRateMinimal = Source.ReadInt32();
Info.Parameters.BlockSize = Source.ReadByte();
Info.Parameters.StopFlag = Source.ReadByte();
if ( Utils.StringEqualsArr(VORBIS_PARAMETERS_ID, Info.Parameters.ID) )
{
Info.SPagePos = (int)fs.Position;
Info.SPage.ID = Source.ReadChars(4);
Info.SPage.StreamVersion = Source.ReadByte();
Info.SPage.TypeFlag = Source.ReadByte();
Info.SPage.AbsolutePosition = Source.ReadInt64();
Info.SPage.Serial = Source.ReadInt32();
Info.SPage.PageNumber = Source.ReadInt32();
Info.SPage.Checksum = Source.ReadInt32();
Info.SPage.Segments = Source.ReadByte();
Info.SPage.LacingValues = Source.ReadBytes(0xFF);
Source.BaseStream.Seek(Info.SPagePos + Info.SPage.Segments + 27, SeekOrigin.Begin);
Info.Tag.ID = Source.ReadChars(7);
// Read Vorbis tag
if ( Utils.StringEqualsArr(VORBIS_TAG_ID, Info.Tag.ID)) ReadTag(Source, ref Info); //# cast implicite douteux
// Get total number of samples
Info.Samples = (int)GetSamples(Source);
result = true;
}
}
}
catch(Exception e)
{
//System.Console.WriteLine(e.StackTrace);
System.Console.WriteLine(e.Message);
result = false;
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
if (Source != null) Source.Close();
}
return result;
}
示例9: ReadFromFile
// ---------------------------------------------------------------------------
public bool ReadFromFile(String FileName)
{
FileStream fs = null;
BinaryReader source = null;
char[] marker = new char[4];
bool result = false;
FResetData();
FAPEtag.ReadFromFile(FileName);
FTagSize = FAPEtag.Size;
try
{
fs = new FileStream(FileName,FileMode.Open, FileAccess.Read);
fs.Lock(0,fs.Length);
source = new BinaryReader(fs);
FFileSize = fs.Length;
//read first bytes
Array.Clear(marker,0,4);
marker = source.ReadChars(4);
fs.Seek( 0, SeekOrigin.Begin );
if ( Utils.StringEqualsArr("RIFF",marker) )
{
result = _ReadV3( source );
}
else
{
if ( Utils.StringEqualsArr("wvpk",marker) )
{
result = _ReadV4( source );
}
}
}
catch (Exception e)
{
System.Console.WriteLine(e.StackTrace);
result = false;
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
fs.Close();
}
return result;
}
示例10: ReadFromFile
// === PUBLIC METHODS ===
public bool ReadFromFile(String fileName)
{
bool result = true;
PSFHeader header = new PSFHeader();
PSFTag tag = new PSFTag();
FResetData();
header.Reset();
tag.Reset();
FileStream fs = null;
BinaryReader source = null;
try
{
fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
fs.Lock(0,fs.Length);
source = new BinaryReader(fs);
if ( !readHeader(ref source, ref header) ) throw new Exception("Not a PSF file");
if (fs.Length > HEADER_LENGTH+header.CompressedProgramLength+header.ReservedAreaLength)
{
fs.Seek((long)(4+header.CompressedProgramLength+header.ReservedAreaLength),SeekOrigin.Current);
if ( !readTag(ref source,ref tag) ) throw new Exception("Not a PSF tag");
}
}
catch (Exception e)
{
System.Console.WriteLine(e.StackTrace);
//LogDelegator.GetLogDelegate()(Log.LV_ERROR, e.Message);
result = false;
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
fs.Close();
}
if (tag.tags.ContainsKey(TAG_GAME)) FAlbum = (String)tag.tags[TAG_GAME];
if (tag.tags.ContainsKey(TAG_ARTIST)) FArtist = (String)tag.tags[TAG_ARTIST];
if (tag.tags.ContainsKey(TAG_COMMENT)) FComment = (String)tag.tags[TAG_COMMENT];
if (tag.tags.ContainsKey(TAG_TITLE)) FTitle = (String)tag.tags[TAG_TITLE];
if (tag.tags.ContainsKey(TAG_YEAR)) FYear = (String)tag.tags[TAG_YEAR];
if (tag.tags.ContainsKey(TAG_LENGTH))
{
FDuration = parsePSFDuration( (String)tag.tags[TAG_LENGTH] );
}
if (tag.tags.ContainsKey(TAG_FADE))
{
FDuration += parsePSFDuration( (String)tag.tags[TAG_FADE] );
}
return result;
}
示例11: proUpFilePackage
//.........这里部分代码省略.........
if (rst != null)
{
cofUPP.State = rst.code;
back.State = cofUPP.State;
switch (cofUPP.State)
{
case 1:// 传输完成
cofUPP.UpCount = back.TotalPacks;
back.UpCount = cofUPP.UpCount;
cofUPP.WakeTimeStamp -=30;
isMC = true;
break;
case -1:
case -2:
cofUPP.WakeTimeStamp -= 30;
break;
}
}
}
// 默认处理
if (rst == null)
{
rst = new UnAttrRst();
rst.code = 0;
rst.msg = "传输中";
}
}
// 文件不是秒传,上传成功处理临时文件
if (!isMC && cofUPP.UpCount == cofUPP.TotalPacks)
{
cofUPP.State = 1;
back.State = cofUPP.State;
// 临时路径
string oldPath = UnUdpHelp.getUpFileReceivePath(cofUPP.HashCode);
if (intServer != null)
{
entity.TmpPath = oldPath;
rst = intServer.upSuccess(point, entity);
if (rst != null)
{
rst.code = 1;
rst.msg = "传输完成";
}
}
// 默认处理
if (rst == null)
{
// 转正式文件
string newPath = UnUdpHelp.getUpFileSavePath(cofUPP.HashCode, cofUPP.Extent);
UnFile.move(oldPath, newPath, true);
rst = new UnAttrRst();
rst.code = 1;
rst.msg = "上传成功";
rst.back = newPath;
}
cofUPP.WakeTimeStamp -= 25;
}
back.PackData = UnInit.getEncoding().GetBytes(UnXMMPXml.tToXml(typeof(UnAttrRst), rst));
data = UnUdpHelp.assemblePackage(back);
return data;
case UnUdpEveEnum.upFilePackage:
// 在区间内且上传未完成
if (entity.PackNo >= cofUPP.IntMin && entity.PackNo <= cofUPP.IntMax && cofUPP.UpCount < cofUPP.TotalPacks)
{
// 是否已传
bool isHave = cofUPP.isReceived.Exists(t => t == entity.PackNo);
if (!isHave)
{
// 写入数据
using (FileStream fs = new FileStream(UnUdpHelp.getUpFileReceivePath(cofUPP.HashCode), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
fs.Lock(entity.PackOffset, entity.PackData.Length);
fs.Seek(entity.PackOffset, SeekOrigin.Begin);
fs.Write(entity.PackData, 0, entity.PackData.Length);
cofUPP.UpCount++;
cofUPP.isReceived.Add(entity.PackNo);
// 修改配置
if (cofUPP.UpCount == cofUPP.IntMax)
{
long[] ls = UnUdpHelp.waitUps(cofUPP.IntMax + 1, entity.TotalPacks, interval);
cofUPP.IntMin = ls[0];
cofUPP.IntMax = ls[1];
cofUPP.isReceived = new List<long>();
}
fs.Unlock(entity.PackOffset, entity.PackData.Length);
}
}
}
back.Event = UnUdpEveEnum.upFilePackageBack.getText();
back.PackNo = entity.PackNo;
back.UpCount = cofUPP.UpCount;
data = UnUdpHelp.assemblePackage(back);
return data;
}
return data;
}
示例12: WriteFile
/// <summary>
/// 打开或创建文件。
/// </summary>
public void WriteFile(string content)
{
DirectoryInfo dirInfo = new DirectoryInfo(FilePath);
if (!dirInfo.Exists)
{
Directory.CreateDirectory(FilePath);
}
string fullFileName = FilePath + FileName;
FileStream fs = null;
try
{
fs = new FileStream(fullFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
lock (this)
{
byte[] buf;
long len;
try
{
buf = utf8.GetBytes(content);
len = fs.Length;
fs.Lock(0, len);
fs.Seek(0, SeekOrigin.End);
fs.Write(buf, 0, buf.Length);
fs.Unlock(0, len);
fs.Flush();
fs.Close();
fs = null;
}
catch (Exception er)
{
throw er;
}
}
}
catch (Exception er)
{
throw er;
}
}
示例13: ReadFromFile
// ---------------------------------------------------------------------------
// No explicit destructor in C#
// ---------------------------------------------------------------------------
// Read data from file
public bool ReadFromFile(String FileName)
{
FileStream fs = null;
BinaryReader Source = null;
bool result = false;
FResetData();
// At first search for tags, then try to recognize header type
FID3v2.ReadFromFile(FileName);
FID3v1.ReadFromFile(FileName);
FAPEtag.ReadFromFile(FileName);
try
{
fs = new FileStream(FileName, FileMode.Open);
fs.Lock(0,fs.Length);
Source = new BinaryReader(fs);
FFileSize = (int)fs.Length;
FHeaderTypeID = FRecognizeHeaderType(Source);
// Read header data
if ( AAC_HEADER_TYPE_ADIF == FHeaderTypeID ) FReadADIF(Source);
if ( AAC_HEADER_TYPE_ADTS == FHeaderTypeID ) FReadADTS(Source);
result = true;
}
catch (Exception e)
{
result = false;
System.Console.WriteLine(e.StackTrace);
//LogDelegator.GetLogDelegate()( Log.LV_ERROR, e.Message);
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
if (Source != null) Source.Close();
}
return result;
}
示例14: ExecuteTask
/// <summary>
/// Causes a thread to be scheduled for execution.
/// </summary>
protected override void ExecuteTask()
{
string ver = SharpPcap.Version.VersionString;
// Get the local processing folders
DirectoryInfo captureDir = new DirectoryInfo(_captureToFolder);
DirectoryInfo processDir = new DirectoryInfo(_processToFolder);
DirectoryInfo outputDir = new DirectoryInfo(_statisticsToFolder);
// Get the local drive for checking disk space
DriveInfo volume = new DriveInfo(outputDir.Root.ToString());
FileInfo pcapFile = null;
string pcapFilename = "";
string pcapFilter = "*.pcap";
DateTime start = DateTime.Now;
do
{
//Check if there are files if not wait 10 sec then check again
do
{
TimeSpan timer = DateTime.Now - start;
int seconds = (int)timer.TotalSeconds;
Console.WriteLine("-> {0} seconds to process.", seconds.ToString());
start = DateTime.Now;
// Null the file until we find one that is unlocked
pcapFile = null;
try
{
foreach (FileInfo p in captureDir.GetFiles(pcapFilter))
{
Console.WriteLine(p.FullName);
if (!this.Running) { break; }
// Check to see if the file is locked using a file stream and FileShare.None
// If the file is not locked, keep it locked for at least a second
FileStream fs = new FileStream(p.FullName, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
fs.Lock(0, fs.Length);
System.Threading.Thread.Sleep(1000);
// Get the file a
pcapFile = p;
pcapFilename = processDir.FullName + "\\" + pcapFile.Name;
long NeededSpace = p.Length * 2; // Double for enough free space for one capture with room remaining
// Unlock and close
fs.Unlock(0, fs.Length);
fs.Close();
// Check available disk space
if (NeededSpace > volume.AvailableFreeSpace)
{
this.parentService.Log(EventLogEntryType.Error, 1, "The disk drive " + outputDir.Root.ToString() + " is too low on disk space to analyze packet capture statistics.");
this.parentService.Stop();
return;
}
// Move the file for processing
pcapFile.MoveTo(pcapFilename);
break;
}
}
catch (System.IO.IOException)
{
// The file selected is locked by another thread or process
pcapFile = null;
}
catch (Exception ex)
{
// Log any errors
this.parentService.Log(EventLogEntryType.Warning,
"{0} thread ({1}) error opening pcap file.\n{2}",
this.ThreadName,
this.ThreadId.ToString(),
ex.ToString());
pcapFile = null;
}
// If we have gotten this far, then no files are available or all files are locked
// Sleep the thread
if (!(pcapFile == null))
System.Threading.Thread.Sleep(10000);
} while (pcapFile == null);
parsePcap(pcapFilename, outputDir);
} while (this.Running);
// End the thread and return
this.Stop();
//.........这里部分代码省略.........
示例15: ReadFromFile
/* -------------------------------------------------------------------------- */
// No explicit destructors with C#
/* -------------------------------------------------------------------------- */
public bool ReadFromFile(String FileName)
{
FileStream fs = null;
BinaryReader source = null;
ushort signatureChunk;
byte tehByte;
bool result = false;
FResetData();
try
{
fs = new FileStream(FileName,FileMode.Open, FileAccess.Read);
fs.Lock(0,fs.Length);
source = new BinaryReader(fs);
signatureChunk = source.ReadUInt16();
if ( /*0x0B77*/ 30475 == signatureChunk )
{
tehByte = 0;
fs.Seek(2, SeekOrigin.Current);
tehByte = source.ReadByte();
FFileSize = fs.Length;
FValid = true;
switch (tehByte & 0xC0)
{
case 0: FSampleRate = 48000; break;
case 0x40: FSampleRate = 44100; break;
case 0x80: FSampleRate = 32000; break;
default : FSampleRate = 0; break;
}
FBitrate = (ushort)BITRATES[(tehByte & 0x3F) >> 1];
tehByte = 0;
fs.Seek(1, SeekOrigin.Current);
tehByte = source.ReadByte();
switch (tehByte & 0xE0)
{
case 0: FChannels = 2; break;
case 0x20: FChannels = 1; break;
case 0x40: FChannels = 2; break;
case 0x60: FChannels = 3; break;
case 0x80: FChannels = 3; break;
case 0xA0: FChannels = 4; break;
case 0xC0: FChannels = 4; break;
case 0xE0: FChannels = 5; break;
default : FChannels = 0; break;
}
FBits = 16;
FDuration = (double)FFileSize * 8 / 1000 / FBitrate;
result = true;
}
}
catch (Exception e)
{
System.Console.WriteLine(e.StackTrace);
result = false;
}
if (fs != null)
{
fs.Unlock(0,fs.Length);
if (source != null) source.Close();
}
return result;
}