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


C# Library.WriteAllBytes方法代码示例

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


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

示例1: FinalizeMultiPass

        /// <summary>
        /// Ends the sequence of creating a content/signature pair.
        /// Writes the list of deleted files to the archives.
        /// </summary>
        /// <param name="signaturefile">The signature archive file</param>
        /// <param name="contentfile">The content archive file</param>
        /// <param name="volumesize">The max volume size</param>
        /// <returns>True if the volume is completed, false otherwise</returns>
        public bool FinalizeMultiPass(Library.Interface.ICompression signaturefile, Library.Interface.ICompression contentfile, long volumesize)
        {
            if (!m_finalized)
            {
                if (m_unproccesed.Files.Count == 0)
                {
                    long stringsize = 0;
                    foreach (string s in m_oldSignatures.Keys)
                    {
                        string sourcefolder = "<unknown>";
                        try
                        {
                            string fullpath = GetFullPathFromRelname(s);
                            sourcefolder = GetSourceFolder(fullpath);
                            if (!m_unproccesed.IsAffectedByError(fullpath))
                            {
                                m_deletedfiles.Add(s);
                                stringsize += System.Text.Encoding.UTF8.GetByteCount(s + "\r\n");
                            }
                        }
                        catch (Exception ex)
                        {
                            if (m_stat != null)
                                m_stat.LogError(string.Format(Strings.RSyncDir.DeletedFilenameError, s, sourcefolder), ex);
                            Logging.Log.WriteMessage(string.Format(Strings.RSyncDir.DeletedFilenameError, s, sourcefolder), XervBackup.Library.Logging.LogMessageType.Error, ex);
                            m_unproccesed.FilesWithError.Add(s);
                        }
                    }

                    m_oldSignatures.Clear();

                    if (m_deletedfiles.Count > 0)
                    {
                        //The +100 is a safety margin
                        stringsize += System.Text.Encoding.UTF8.GetByteCount(DELETED_FILES) + 100;
                        if (contentfile.Size + contentfile.FlushBufferSize + stringsize > volumesize)
                            return false; //The followup cannot fit in the volume, so we make a full new volume

                        signaturefile.WriteAllLines(DELETED_FILES, m_deletedfiles.ToArray());
                        contentfile.WriteAllLines(DELETED_FILES, m_deletedfiles.ToArray());
                        m_deletedfiles.Clear();
                    }

                    //We only write the USN if all files were processed
                    if (m_currentUSN != null)
                        using (System.IO.Stream s = signaturefile.CreateFile(USN_VALUES))
                            m_currentUSN.Save(s);

                    //Only write this if all files were processed
                    if (m_checkedUnchangedFiles.Count > 0)
                        signaturefile.WriteAllLines(UNMODIFIED_FILES, m_checkedUnchangedFiles.ToArray());

                    if (m_unproccesed.Symlinks.Count > 0)
                    {
                        foreach(KeyValuePair<string, string> kvp in m_unproccesed.Symlinks)
                        {
                            string target = FilenamesToPlatformIndependant(new string[] { kvp.Value })[0];
                            string source = Path.Combine(SYMLINK_ROOT, GetRelativeName(kvp.Key));
                            byte[] targetBytes = Encoding.UTF8.GetBytes(target);

                            contentfile.WriteAllBytes(source, targetBytes);
                            signaturefile.WriteAllBytes(source, targetBytes);
                        }
                        m_unproccesed.Symlinks.Clear();
                    }
                }

                m_finalized = true;
            }

            return m_finalized;
        }
开发者ID:ZlayaZhaba,项目名称:XervBackup,代码行数:80,代码来源:RSyncDir.cs


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