C# (CSharp) Stream.Close Beispiele

C# (CSharp) Stream.Close - 30 Beispiele gefunden. Dies sind die am besten bewerteten C# (CSharp) Beispiele für die Stream.Close, die aus Open Source-Projekten extrahiert wurden. Sie können Beispiele bewerten, um die Qualität der Beispiele zu verbessern.
        private static void CopyAsync(byte[] buffer, FileStream inputStream, Stream outputStream, TaskCompletionSource<object> tcs)
        {
            inputStream.ReadAsync(buffer).Then(read =>
            {
                if (read > 0)
                {
                    outputStream.WriteAsync(buffer, 0, read)
                                .Then(() => CopyAsync(buffer, inputStream, outputStream, tcs))
                                .Catch(ex =>
                                {
                                    inputStream.Close();
                                    outputStream.Close();
                                    tcs.SetException(ex);
                                });
                }
                else
                {
                    inputStream.Close();
                    outputStream.Close();

                    tcs.SetResult(null);
                }
            })
            .Catch(ex =>
            {
                inputStream.Close();
                outputStream.Close();

                tcs.SetException(ex);
            });
        }
 public Sims3Pack(string FileName)
     : this()
 {
     IsEncrypted = false;
     DataStore = File.Open(FileName, FileMode.Open, FileAccess.Read,FileShare.Read);
     try
     {
         Import();
     }
     catch (InvalidDataException e)
     {
         DataStore.Close();
         if (e.Message == "DBPP Not Supported") IsEncrypted = true;
         //throw e;
     }
     catch (XmlException)
     {
         DataStore.Close();
         IsCorrupt = true;
         // throw e;
     }
     catch (EndOfStreamException)
     {
         DataStore.Close();
         IsCorrupt = true;
         //throw e;
     }
 }
Beispiel #3
0
		public PckFile(Stream pckFile, Stream tabFile,int bpp,Palette pal,int imgHeight,int imgWidth)
		{
			if(tabFile!=null)
				tabFile.Position=0;

			pckFile.Position=0;

			byte[] info = new byte[pckFile.Length];
			pckFile.Read(info,0,info.Length);
			pckFile.Close();

			this.bpp=bpp;

			Pal=pal;

			uint[] offsets;
			
			if(tabFile!=null)
			{
				offsets= new uint[(tabFile.Length/bpp)+1];
				BinaryReader br = new BinaryReader(tabFile);

				if(bpp==2)
					for(int i=0;i<tabFile.Length/bpp;i++)
						offsets[i] = br.ReadUInt16();
				else
					for(int i=0;i<tabFile.Length/bpp;i++)
						offsets[i] = br.ReadUInt32();
				br.Close();
			}
			else
			{
				offsets = new uint[2];
				offsets[0]=0;
			}

			offsets[offsets.Length-1] = (uint)info.Length;

			for(int i=0;i<offsets.Length-1;i++)
			{
				byte[] imgDat = new byte[offsets[i+1]-offsets[i]];
				for(int j=0;j<imgDat.Length;j++)			
					imgDat[j] = info[offsets[i]+j];

				Add(new PckImage(i,imgDat,pal,this,imgHeight,imgWidth));
			}

			pckFile.Close();
			if(tabFile!=null)
				tabFile.Close();
		}
Beispiel #4
0
 /// <summary>Creates a new AudioReader that can read the specified soundstream.</summary>
 /// <param name="s">The System.IO.Stream to read from.</param>
 /// <returns>A new OpenTK.Audio.AudioReader, which can be used to read from the specified sound stream.</returns>
 public AudioReader(Stream s)
 {
     try
     {
         lock (reader_lock)
         {
             foreach (AudioReader reader in readers)
             {
                 long pos = s.Position;
                 if (reader.Supports(s))
                 {
                     s.Position = pos;
                     implementation = (AudioReader)
                         reader.GetType().GetConstructor(
                             System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public |
                             System.Reflection.BindingFlags.Instance,
                             null,
                             new Type[] { typeof(Stream) },
                             null)
                         .Invoke(new object[] { s });
                     return;
                 }
                 s.Position = pos;
             }
         }
     }
     catch (Exception)
     {
         s.Close();
         throw;
     }
     throw new NotSupportedException("Could not find a decoder for the specified sound stream.");
 }
        async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {
                var buffer = new byte[_chunkSize];
                using (var inputStream = OpenInputStream())
                {
                    var length = (int)inputStream.Length;
                    var bytesRead = 1;

                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = inputStream.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }
            }
            catch (HttpException)
            {
            }
            finally
            {
                outputStream.Close();
                outputStream.Dispose();
            }
        }
Beispiel #6
0
        public static void SaveStreamToFile(Stream stream, string cachePath)
        {
            IsolatedStorageFileStream fileStream = null;
            try
            {
                byte[] buffer = new byte[stream.Length];

                IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
                if (!store.FileExists(cachePath))
                {
                    fileStream = store.CreateFile(cachePath);

                    stream.Read(buffer, 0, buffer.Length);
                    fileStream.Write(buffer, 0, buffer.Length);
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
        }
Beispiel #7
0
 public Stream Decode(Stream stream)
 {
     const int bufsize = 32768;
     BinaryReader breader = new BinaryReader(stream);
     byte[] bbuffer = breader.ReadBytes(2);
     stream.Position = 0;
     if ((bbuffer[0] == 31) && (bbuffer[1] == 139)) {
         using (GZipStream zipStream = new GZipStream(stream, CompressionMode.Decompress)) {
             MemoryStream ms = new MemoryStream();
             using (BinaryReader zipreader = new BinaryReader(zipStream)) {
                 while (true) {
                     bbuffer = zipreader.ReadBytes(bufsize);
                     ms.Write(bbuffer, 0, bbuffer.Length);
                     if (bbuffer.Length < bufsize) {
                         break;
                     }
                 }
             }
             stream.Close();
             ms.Position = 0;
             return ms;
         }
     }
     return stream;
 }
        public static DataTable RenderDataTableFromExcel(Stream ExcelFileStream, string SheetName, int HeaderRowIndex)
        {
            HSSFWorkbook workbook = new HSSFWorkbook(ExcelFileStream);
            HSSFSheet sheet = workbook.GetSheet(SheetName);

            DataTable table = new DataTable();

            HSSFRow headerRow = sheet.GetRow(HeaderRowIndex);
            int cellCount = headerRow.LastCellNum;

            for (int i = headerRow.FirstCellNum; i < cellCount; i++)
            {
                DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);
                table.Columns.Add(column);
            }

            int rowCount = sheet.LastRowNum;

            for (int i = (sheet.FirstRowNum + 1); i < sheet.LastRowNum; i++)
            {
                HSSFRow row = sheet.GetRow(i);
                DataRow dataRow = table.NewRow();

                for (int j = row.FirstCellNum; j < cellCount; j++)
                    dataRow[j] = row.GetCell(j).ToString();
            }

            ExcelFileStream.Close();
            workbook = null;
            sheet = null;
            return table;
        }
        public static string UploadDocument(Stream stream, string filePath, string fileName)
        {
            int pos = fileName.LastIndexOf('.');
            string extFile = string.Empty;
            extFile = fileName.Substring(pos);
            string uploadFilename = Guid.NewGuid().ToString();
            try
            {
                stream.Seek(0, SeekOrigin.Begin);

                using (FileStream fileStream = new FileStream(filePath + uploadFilename + extFile, FileMode.Create, FileAccess.Write))
                {
                    byte[] buffer = new byte[Constants.BUFFER_SIZE];
                    int bufferSize = 0;
                    do
                    {
                        bufferSize = stream.Read(buffer, 0, buffer.Length);
                        fileStream.Write(buffer, 0, bufferSize);
                    } while (bufferSize > 0);
                    stream.Close();
                    fileStream.Close();
                }
            }
            catch (ApplicationException)
            {
                throw;
            }
            catch (Exception ex)
            {
                log4net.Util.LogLog.Error(ex.Message, ex);
            }
            return uploadFilename + extFile;
        }
Beispiel #10
0
            public EasyWebRequest(string method, string userName, string password, string authID, string masterKey, string baseURL, string contraint)
            {
                request = WebRequest.Create(baseURL);
                request.ContentType = "text/xml";
                request.Credentials = new NetworkCredential(userName, password);
                request.Headers.Add("X-Parse-Application-Id: " + authID);
                request.Headers.Add("X-Parse-Master-Key: " + masterKey);

                if (method.Equals("GET") || method.Equals("POST"))
                    request.Method = method;
                else
                    throw new Exception("Invalid Method Type");

                string postData = contraint;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);

                request.ContentType = "application/x-www-form-urlencoded";

                request.ContentLength = byteArray.Length;

                dataStream = request.GetRequestStream();

                dataStream.Write(byteArray, 0, byteArray.Length);

                dataStream.Close();
 
            }
Beispiel #11
0
        public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {
                var buffer = new byte[65536];

                using (var video = new MemoryStream(this.videoData))
                {
                    var length = (int)video.Length;
                    var bytesRead = 1;

                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
            finally
            {
                outputStream.Close();
            }
        }
Beispiel #12
0
        /// <summary>
        /// Gets the file hash from a file stream.
        /// </summary>
        /// <returns>The file hash.</returns>
        /// <param name="fileStream">File stream.</param>
        public static string GetFileHash(Stream fileStream)
        {
			if (fileStream != null)
			{
				try
				{
					using (MD5 md5 = MD5.Create())
					{
						//calculate the hash of the stream.
						string resultString = BitConverter.ToString(md5.ComputeHash(fileStream)).Replace("-", "");

						return resultString;
					}
				}
				catch (IOException ioex)
				{
					Console.WriteLine ("IOException in GetFileHash(): " + ioex.Message);

					return String.Empty;
				}
				finally
				{
					//release the file (if we had one)
					fileStream.Close();
				}
			}     
			else
			{ 
				return String.Empty;
			}
        }
Beispiel #13
0
 public void Close(Stream stream)
 {
     if (stream != null)
     {
         stream.Close();
     }
 }
        /// <summary>
        /// HTTPS POST
        /// </summary>
        /// <param name="url"></param>
        /// <param name="postStream"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static string HttpPost(string url ,Stream  postStream,Encoding encoding = null)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postStream != null ? postStream.Length : 0;
            request.Accept = "text/html,application/xhtml+xml,application/xml";
            request.KeepAlive = true;
            request.UserAgent = "Mozilla/5.0 (Winodws NT 6.1; WOW64) AppleWebkit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
            if (postStream != null)
            {
                postStream.Position = 0;
                Stream requestStream = request.GetRequestStream();
                byte[] buffer = new byte[1024];
                int bytesRead = 0;
                while ((bytesRead=postStream.Read(buffer,0,buffer.Length))!=0)
                {
                    requestStream.Write(buffer, 0, bytesRead);
                }
                postStream.Close();
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            using (Stream responseStream = response.GetResponseStream())
            {
                using (StreamReader myStreamReader = new StreamReader(responseStream, encoding ?? Encoding.UTF8))
                {
                    string retString = myStreamReader.ReadToEnd();

                    return retString;
                }
            }
        }
 public static IEnumerable<AzureSubscription> ImportAzureSubscription(Stream stream, ProfileClient azureProfileClient, string environment)
 {
     var publishData = DeserializePublishData(stream);
     PublishDataPublishProfile profile = publishData.Items.Single();
     stream.Close();
     return profile.Subscription.Select(s => PublishSubscriptionToAzureSubscription(azureProfileClient, profile, s, environment));
 }
Beispiel #16
0
        private void CopyWithLambda(Stream s, Stream d, ref long total)
        {
            var buffer = new byte[4096];
            try
            {
                while (true)
                {
                    var read = s.Read(buffer, 0, 4096);
                    if (read == 0)
                        break;
                    var tmpTotal = Interlocked.Add(ref total, read);
					if (VetoTransfer(tmpTotal, new ArraySegment<byte>(buffer, 0, read)))
                    {
                        //force close of both streams
                        s.Close();
                        d.Close();
                        throw new Exception("Transfer vetoed!");
                    }

                    d.Write(buffer, 0, read);
                    if (IsEndOfChunkEncoding(buffer, 0, read))
                    {
                        break;
                    }
                }
            }
            catch (IOException)
            {
            }

        }
        public bool sendMessage_ToServer(String message)
        {
            bool state = false;
            try
            {
                tcpClient.Connect(IPAddress.Parse("127.0.0.1"), 6000);
                if (tcpClient.Connected)
                {
                    stm = tcpClient.GetStream();
                    byte[] buffer = ascii.GetBytes(message);
                    stm.Write(buffer, 0, buffer.Length);
                    stm.Close();
                    state = true;
                }
                else
                {
                    Console.WriteLine("Server is unreachable.....");
                    state = false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Message Sending Failed...... \n" + e.StackTrace);

            }
            finally {
                tcpClient.Close();
            }

            return state;
        }
Beispiel #18
0
        // Source: http://blogs.msdn.com/b/feroze_daud/archive/2004/03/30/104440.aspx
        public static String Decode(WebResponse response, Stream stream)
        {
            String charset = null;
            String contentType = response.Headers["content-type"];
            if(contentType != null)
            {
                int index = contentType.IndexOf("charset=");
                if(index != -1)
                {
                    charset = contentType.Substring(index + 8);
                }
            }

            MemoryStream data = new MemoryStream();
            byte[] buffer = new byte[1024];
            int read = stream.Read(buffer, 0, buffer.Length);
            while(read > 0)
            {
                data.Write(buffer, 0, read);
                read = stream.Read(buffer, 0, buffer.Length);
            }
            stream.Close();

            Encoding encoding = Encoding.UTF8;
            try
            {
                if(charset != null)
                    encoding = Encoding.GetEncoding(charset);
            }
            catch { }

            data.Seek(0, SeekOrigin.Begin);
            StreamReader streamReader = new StreamReader(data, encoding);
            return streamReader.ReadToEnd();
        }
        public void loadDDS(Stream input)
        {
            this.lockImage = true;

            ddsFile.Load(input);
            pictureBox1.Image = ddsFile.Image();

            toolStripStatusLabel1.Text = "";
            toolStripStatusLabel2.Text = "W: " + ddsFile.m_header.m_width.ToString();
            toolStripStatusLabel3.Text = "H: " + ddsFile.m_header.m_height.ToString();
            if (ddsFile.m_header.m_pixelFormat.m_rgbBitCount.ToString() != "0" && ddsFile.m_header.m_pixelFormat.m_rgbBitCount.ToString() != "")
            {
                toolStripStatusLabel4.Text = ddsFile.m_header.m_pixelFormat.m_rgbBitCount.ToString() + "bit";
                toolStripStatusLabel4.Visible = true;
            }
            else
            {
                toolStripStatusLabel4.Visible = false;
            }

            toolStripStatusLabel5.Text = ddsFile.m_header.fileFormat;

            chkShowRed.Checked = true;
            chkShowGreen.Checked = true;
            chkShowBlue.Checked = true;
            chkShowAlpha.Checked = false;

            input.Close();

            this.lockImage = false;
        }
Beispiel #20
0
        public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {
                var buffer = new byte[65536];

                using (var media = File.Open(_filename, FileMode.Open, FileAccess.Read))
                {
                    var length = (int)media.Length;
                    var bytesRead = 1;

                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = media.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new BlogException(ex.Message, ex);
            }
            finally
            {
                outputStream.Close();
            }
        }
Beispiel #21
0
        private static byte[ ] ComputeMovieHash( Stream input )
        {
            long lhash, streamsize;
            streamsize = input.Length;
            lhash = streamsize;

            long i = 0;
            byte[ ] buffer = new byte[ sizeof ( long ) ];
            while ( i < 65536 / sizeof ( long ) && ( input.Read( buffer, 0, sizeof ( long ) ) > 0 ) )
            {
                i++;
                lhash += BitConverter.ToInt64( buffer, 0 );
            }

            input.Position = Math.Max( 0, streamsize - 65536 );
            i = 0;
            while ( i < 65536 / sizeof ( long ) && ( input.Read( buffer, 0, sizeof ( long ) ) > 0 ) )
            {
                i++;
                lhash += BitConverter.ToInt64( buffer, 0 );
            }
            input.Close( );
            byte[ ] result = BitConverter.GetBytes( lhash );
            Array.Reverse( result );
            return result;
        }
        public void CloseStream(Stream stream)
        {
            Debug.Assert(stream != null);
            Debug.Assert(stream is FileStream);

            stream.Close();
        }
Beispiel #23
0
		public PckFile(Stream pckFile, Stream tabFile,int bpp)
		{
			byte[] info = new byte[pckFile.Length];
			pckFile.Read(info,0,info.Length);
			pckFile.Close();

			this.pal=DefaultPalette;

			uint[] offsets = new uint[(tabFile.Length/bpp)+1];
			BinaryReader br = new BinaryReader(tabFile);

			if(bpp==2)
				for(int i=0;i<tabFile.Length/bpp;i++)
					offsets[i] = br.ReadUInt16();
			else
				for(int i=0;i<tabFile.Length/bpp;i++)
					offsets[i] = br.ReadUInt32();

			offsets[offsets.Length-1] = (uint)info.Length;

			images = new ArrayList(offsets.Length-1);

			for(int i=0;i<offsets.Length-1;i++)
			{
				byte[] imgDat = new byte[offsets[i+1]-offsets[i]];
				for(int j=0;j<imgDat.Length;j++)			
					imgDat[j] = info[offsets[i]+j];

				images.Add(new PckImage(i,imgDat,pal));

				if(LoadingEvent!=null)
					LoadingEvent(i,offsets.Length-1);
			}	
			br.Close();
		}
Beispiel #24
0
        public async Task StreamVideo(Stream stream, HttpContent content, TransportContext transport)
        {
            try
            {
                var buffer = new byte[65536];
                var filename = Path.Combine(String.Format("{0}{1}video.{2}", System.Web.HttpContext.Current.Server.MapPath("~"), Constants.FilePath, _fileExtension));
                using (var file = File.Open(filename, FileMode.Open, FileAccess.Read))
                {
                    var videoLength = (int)file.Length;
                    var placeInFile = 1;

                    while (videoLength > 0 && placeInFile > 0)
                    {
                        placeInFile = file.Read(buffer, 0, Math.Min(videoLength, buffer.Length));
                        await stream.WriteAsync(buffer, 0, placeInFile);
                        videoLength -= placeInFile;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.InnerException);
            }
            finally
            {
                stream.Close();
            }
        }
Beispiel #25
0
        /// <summary>
        /// Копирование из потока в поток
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        public static void CopyStream(Stream input, Stream output)
        {
            try
            {
                int bufferSize = 4096;

                byte[] buffer = new byte[bufferSize];

                while (true)
                {
                    int read = input.Read(buffer, 0, buffer.Length);

                    if (read <= 0)
                    {
                        input.Flush();
                        input.Close();

                        return;
                    }

                    output.Write(buffer, 0, read);
                }
            }
            catch (Exception ex)
            {
                DebugHelper.WriteLogEntry(ex, "Streem copy error");
                output = null;
            }
        }
        public async void WriteToStream(Stream outputStream, HttpContent content, TransportContext context)
        {
            try
            {

              var channelBinding=   context.GetChannelBinding(ChannelBindingKind.Endpoint);

                var buffer = new byte[65536];
                using (var video = File.Open(_filename, FileMode.Open, FileAccess.Read))
                {
                    var length = (int)video.Length;
                    var bytesRead = 1;
                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }
            }
            catch (HttpResponseException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                outputStream.Close();
            }
        }
Beispiel #27
0
 public object Deserialize(Stream buffer)
 {
     Alachisoft.NCache.Common.Protobuf.Command command = null;
     command = ProtoBuf.Serializer.Deserialize<Alachisoft.NCache.Common.Protobuf.Command>(buffer);
     buffer.Close();
     return command;
 }
        private Task ConvertStream(HttpContent httpContent, Stream outputStream)
        {
            Task convertTask = new Task(() => {

                var convertSettings = new ConvertSettings {
                    CustomOutputArgs = "-map 0",
                    CustomInputArgs = "-vcodec h264"
                };

                var ffMpeg = new FFMpegConverter();
                ffMpeg.ConvertProgress += FfMpeg_ConvertProgress;
                ffMpeg.LogReceived += FfMpeg_LogReceived;

                //var task = ffMpeg.ConvertLiveMedia(Format.h264, "C:\\Work\\Test\\converted.avi", Format.avi, convertSettings);
                var task = ffMpeg.ConvertLiveMedia(Format.h264, outputStream, Format.mpeg, convertSettings);

                task.Start();

                var ffmpegStream = new FFMPegStream(task);
                var copyTask = httpContent.CopyToAsync(ffmpegStream);
                copyTask.Wait();
                ffmpegStream.Close();

                task.Wait();

                //                ffMpeg.ConvertMedia(@"C:\Work\Test\MyHomeSecureNode\devices\test\video.h264", "C:\\Work\\Test\\converted.avi", Format.avi);

                outputStream.Close();
            });

            convertTask.Start();
            return convertTask;
        }
Beispiel #29
0
 private static void DisposeObject(ref HttpWebRequest request, ref HttpWebResponse response,
     ref Stream responseStream, ref StreamReader reader)
 {
     if (request != null)
     {
         request = null;
     }
     if (response != null)
     {
         response.Close();
         response = null;
     }
     if (responseStream != null)
     {
         responseStream.Close();
         responseStream.Dispose();
         responseStream = null;
     }
     if (reader != null)
     {
         reader.Close();
         reader.Dispose();
         reader = null;
     }
 }
 private void RestoreFromFile(Stream file)
 {
         //
         //
         using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
                 using (var zip = new ZipInputStream(file)) {
                         try {
                                 while (true) {
                                         var ze = zip.GetNextEntry();
                                         if (ze == null) break;
                                         using (var f = new IsolatedStorageFileStream(ze.Name, FileMode.Create, store)) {
                                                 var fs = new byte[ze.Size];
                                                 zip.Read(fs, 0, fs.Length);
                                                 f.Write(fs, 0, fs.Length);
                                         }
                                 }
                         } catch {
                                 lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreFailed;
                                 App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreFailed);
                                 return;
                         } finally {
                                 file.Close();
                                 ClearOldBackupFiles();
                                 App.ViewModel.IsRvDataChanged = true;
                         }
                 }
         }
         lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreSuccess;
         App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreSuccess);
 }