Paradox Community

Items in pnews.paradox-discussions

Subject:Re: BDE_Error-If_Free_Disk_Space_Exceeds_4GB - MORE
Date:Fri, 18 Dec 2020 13:59:45 +0100
From:modridirkac <jure.zorko@gmail.com>
Newsgroups:pnews.paradox-discussions
Copy to visual studio, framework 4.5, command line program.

In paradox, just call it:
    execute(fullname(":tools:bde4gb_fill.exe")+" "+workingdir(),true)


--------------------------------------------------------------------
using System;
using System.IO;

namespace bde4gb_fill
{
     class Program
     {
         static void Main(string[] args)
         {
             if (args.Length == 0)
             {
                 System.Console.WriteLine("Please enter a valid path as  
first parameter");
                 return;
             }

             string path = args[0];
             if (!Directory.Exists(path))
             {
                 System.Console.WriteLine("Please enter a valid path.");
                 return;
             }


             FileInfo file = new FileInfo(path);
             DriveInfo drive = new DriveInfo(file.Directory.Root.FullName);
             System.Console.WriteLine(drive.ToString());

             Decimal siz = drive.AvailableFreeSpace;
             System.Console.WriteLine("Available Free Space : " +  
siz.ToString() + "(bytes)");

             // how much over 4GB?
             Decimal over = siz;
             while (over > 4294967296)
             { over = over - 4294967296; }
             System.Console.WriteLine("Over 4GB:" +  
(over/1024/1024).ToString() + "(Mb)");


             string big_name = "big_file.txt";
             big_name = Path.Combine(path, big_name);

             if (over<536870912) // if lesss than 500Mb free
             { if (File.Exists(big_name))
                 { // delete file
                     File.Delete(big_name);
                     System.Console.WriteLine("Big file name:" + big_name);
                     System.Console.WriteLine("file deleted");
                 }
                 else
                 {   // create 600Mb file
                     // but only if thee is really enough space
                     if (siz > 536870912)
                     using (var fileStream = new FileStream(@big_name,  
FileMode.Create, FileAccess.Write, FileShare.None))
                     {
                         fileStream.SetLength(6442450944);
                     }
                     System.Console.WriteLine("Big file name:" + big_name);
                     System.Console.WriteLine("file created");
                 }
             }
#if DEBUG
             System.Console.ReadLine();
#endif


         }
     }
}


Copyright © 2004 thedbcommunity.com