当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFileStream.CopyTo方法代码示例

本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFileStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFileStream.CopyTo方法的具体用法?C# IsolatedStorageFileStream.CopyTo怎么用?C# IsolatedStorageFileStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IsolatedStorage.IsolatedStorageFileStream的用法示例。


在下文中一共展示了IsolatedStorageFileStream.CopyTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFileStream

        public static Stream GetFileStream(string file)
        {
            Stream stream = null;

            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!isf.FileExists(file))
                {
                    using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream(file, FileMode.Open, isf))
                    {
                        fs.CopyTo(stream, (int)fs.Length);
                    }
                }
            }

            return stream;
        }
开发者ID:kjiwu,项目名称:MyNotebook,代码行数:17,代码来源:IsolatedStorageHelper.cs

示例2: SaveVideoClip

        /// <summary>
        /// Resaves video clip from temporary directory to persistent 
        /// </summary>
        private VideoResult SaveVideoClip()
        {
            try
            {
                using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (string.IsNullOrEmpty(filePath) || (!isoFile.FileExists(filePath)))
                    {
                        return new VideoResult(TaskResult.Cancel);
                    }

                    string fileName = String.Format(FileNameFormat, Guid.NewGuid().ToString());
                    string newPath = Path.Combine("/" + LocalFolderName + "/", fileName);
                    isoFile.CopyFile(filePath, newPath);
                    isoFile.DeleteFile(filePath);

                    memoryStream = new MemoryStream();
                    using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(newPath, FileMode.Open, isoFile))
                    {
                        fileStream.CopyTo(memoryStream);
                    }

                    VideoResult result = new VideoResult(TaskResult.OK);
                    result.VideoFileName = newPath;
                    result.VideoFile = this.memoryStream;
                    result.VideoFile.Seek(0, SeekOrigin.Begin);
                    return result;
                }

            }
            catch (Exception)
            {
                return new VideoResult(TaskResult.None);
            }
        }
开发者ID:hellobr,项目名称:phonegap-projects,代码行数:38,代码来源:VideoRecorder.xaml.cs

示例3: GetReport

		private static Stream GetReport() {
			var stream = new MemoryStream();
			try {
				var writer = new StreamWriter(stream, Encoding.UTF8);
				writer.WriteLine(reportOriginIdentity.ToString("B"));
				writer.WriteLine(Util.LibraryVersion);
				writer.WriteLine(".NET Framework {0}", Environment.Version);

				foreach (var observation in observations) {
					observation.Flush();
					writer.WriteLine("====================================");
					writer.WriteLine(observation.FileName);
					try {
						using (var fileStream = new IsolatedStorageFileStream(observation.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, file)) {
							writer.Flush();
							fileStream.CopyTo(writer.BaseStream);
						}
					} catch (FileNotFoundException) {
						writer.WriteLine("(missing)");
					}
				}

				// Not all event counters may have even loaded in this app instance.
				// We flush the ones in memory, and then read all of them off disk.
				foreach (var counter in events.Values) {
					counter.Flush();
				}

				foreach (string eventFile in file.GetFileNames("event-*.txt")) {
					writer.WriteLine("====================================");
					writer.WriteLine(eventFile);
					using (var fileStream = new IsolatedStorageFileStream(eventFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, file)) {
						writer.Flush();
						fileStream.CopyTo(writer.BaseStream);
					}
				}

				// Make sure the stream is positioned at the beginning.
				writer.Flush();
				stream.Position = 0;
				return stream;
			} catch {
				stream.Dispose();
				throw;
			}
		}
开发者ID:vonbv,项目名称:dotnetopenid,代码行数:46,代码来源:Reporting.cs

示例4: StartVideoRecording

        } // StartVideoRecording()

        private void StopVideoRecording()
        {
            try
            {
                // Stop recording.
                if (captureSource.VideoCaptureDevice != null
                && captureSource.State == CaptureState.Started)
                {
                    captureSource.Stop();

                    // Disconnect fileSink.
                    fileSink.CaptureSource = null;
                    fileSink.IsolatedStorageFileName = null;
                    
                    // Set the button states and the message.
                    UpdateUI(ButtonState.Stopped, "Recording stopped...");

                    viewfinderRectangle.Fill = null;

                    // Create the file stream 
                    isoVideoFile = new IsolatedStorageFileStream(fileName,
                                            FileMode.Open, FileAccess.Read,
                                            IsolatedStorageFile.GetUserStoreForApplication());

                    MemoryStream videoStream = new MemoryStream();
                    using (isoVideoFile)
                    {
                        isoVideoFile.CopyTo(videoStream);
                    }

                    PurposeColor.screens.AddEventsSituationsOrThoughts.ReceiveVideoFromWindows(videoStream, isoVideoFile.Name);
                    
                    isoVideoFile.Flush();
                    isoVideoFile.Dispose();
                    isoVideoFile = null;
                    //videoStream = null;

                    DisposeVideoRecorder();

                }
            }
            // If stop fails, display an error.
            catch (Exception e)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    txtDebug.Text = "ERROR: " + e.Message.ToString();
                });
            }
        }//StopVideoRecording()
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:52,代码来源:VideoCamera.xaml.cs

示例5: Load

        /// <summary>
        /// Loads the State from Isolated Storage (in user store for domain)
        /// </summary>
        /// <remarks>
        /// Sets <see cref="IsLoaded" /> after it's finished to prevent a race condition with saving the state to the MemoryStream.
        /// </remarks>
        public virtual void Load()
        {
            // Don't save or load state in design mode
            if (DesignerProperties.GetIsInDesignMode(this.ribbon))
            {
                Debug.WriteLine("State not loaded from isolated storage. Because we are in design mode.");
                this.IsLoaded = true;
                return;
            }

            if (this.ribbon.AutomaticStateManagement == false)
            {
                this.IsLoaded = true;
                Debug.WriteLine("State not loaded from isolated storage. Because automatic state management is disabled.");
                return;
            }

            try
            {
                var storage = GetIsolatedStorageFile();
                if (IsolatedStorageFileExists(storage, this.IsolatedStorageFileName))
                {
                    using (var stream = new IsolatedStorageFileStream(this.IsolatedStorageFileName, FileMode.Open, FileAccess.Read, storage))
                    {
                        this.Load(stream);

                        // Copy loaded state to MemoryStream for temporary storage.
                        // Temporary storage is used for style changes etc. so we can apply the current state again.
                        stream.Position = 0;
                        this.memoryStream.Position = 0;
                        stream.CopyTo(this.memoryStream);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"Error while trying to load Ribbon state. Error: {ex}");
            }

            this.IsLoaded = true;
        }
开发者ID:VladMorzhanov,项目名称:Study-Csharp-Projects-2015,代码行数:47,代码来源:RibbonStateStorage.cs

示例6: LoadAudioBuffer

        /// <summary>
        /// Loads an audio buffer from isolated storage.
        /// </summary>
        public void LoadAudioBuffer(String fileName)
        {
            // Set the stream back to zero in case there is already something in it
            stream.SetLength(0);

            // Retrieve the named audio file from the storage.
            IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                using (var isoFileStream = new IsolatedStorageFileStream(
                    fileName,
                    FileMode.Open,
                    myStore))
                {
                    isoFileStream.CopyTo(stream);
                    stream.Flush();
                }
            }
            catch
            {
                MessageBox.Show("Error while trying to load audio buffer.");
            }
        }
开发者ID:hutchgard,项目名称:audio-recorder,代码行数:27,代码来源:AudioModel.cs

示例7: ReadFromIsolatedStorage

        /// <summary>
        /// Read Isolated Storage file to memory
        /// </summary>
        /// <param name="fileName">filename</param>
        /// <returns>MemoryStream</returns>
        private static MemoryStream ReadFromIsolatedStorage(string fileName)
        {
            MemoryStream stream = new MemoryStream();

            IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();

            if (isoStore.FileExists(fileName))
            {
                Console.WriteLine(fileName + " file read success.");
                using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(fileName, FileMode.Open, isoStore))
                {
                    isoStream.CopyTo(stream);
                }
            }
            else
            {
                throw new Exception("Could not read from file");
            }

            return stream;
        }
开发者ID:jasonkuster,项目名称:MetroLooper,代码行数:26,代码来源:FileHelper.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFileStream.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。