static public void writeLinuxScriptIfModified(string path, string fileContents)
        {
            Chilkat.FileAccess fac = new Chilkat.FileAccess();
            fac.DirAutoCreate(path);

            // The file does not exist yet, so write it.
            if (!System.IO.File.Exists(path))
            {
                System.IO.File.WriteAllText(path, fileContents);
                return;
            }

            // Make sure to use bare-LF line endings.
            fileContents = fileContents.Replace("\r", "");

            string curFileContents = System.IO.File.ReadAllText(path);

            if (curFileContents.Equals(fileContents))
            {
                return;
            }

            // The file has been modified, so write it..
            System.IO.File.WriteAllText(path, fileContents);
            return;
        }
Beispiel #2
0
        private static void PerformFileSplit()
        {
            var bundledFilePath = GetBundledFilePath();

            var fac = new Chilkat.FileAccess();

            var fileInfo = new FileInfo(bundledFilePath);

            var partPrefix    = $"{fileInfo.Name}_";
            var partExtension = fileInfo.Extension;
            var maxChunkSize  = 2000000;
            var destDirPath   = fileInfo.DirectoryName;

            //  Splits hamlet.xml into hamlet1.part, hamlet2.part, ...
            //  Output files are written to the current working directory.
            //  Each chunk will be 50000 bytes except for the last which
            //  will be the remainder.
            var success = fac.SplitFile(bundledFilePath, partPrefix, partExtension, maxChunkSize, destDirPath);

            Console.WriteLine(success ? "Success." : fac.LastErrorText);
        }
        static public void writeFileIfModified(string path, string fileContents)
        {
            Chilkat.FileAccess fac = new Chilkat.FileAccess();
            fac.DirAutoCreate(path);

            // The file does not exist yet, so write it.
            if (!System.IO.File.Exists(path))
            {
                System.IO.File.WriteAllText(path, fileContents);
                return;
            }

            string curFileContents = System.IO.File.ReadAllText(path);

            if (curFileContents.Equals(fileContents))
            {
                return;
            }

            // The file has been modified, so write it..
            System.IO.File.WriteAllText(path, fileContents);
            return;
        }
 public bool ensureDirExists(string path)
 {
     Chilkat.FileAccess fac = new Chilkat.FileAccess();
     return(fac.DirAutoCreate(path));
 }