Example #1
0
        public void UploadFile(RemoteFileInfo request)
        {
            FileStream targetStream = null;
            Stream     sourceStream = request.FileByteStream;

            DirectoryInfo dirinf  = new DirectoryInfo(Path.Combine(@"D:\Cursova\Clients\", request.uploadFolder.Split('\\')[0]));
            long          sizeInf = SizeInfo.GetSize(dirinf);

            sizeInf += request.Length;

            if ((sizeInf / Math.Pow(1024, 3)) >= 1)
            {
                return;
            }
            else
            {
                string filePath = Path.Combine(@"D:\Cursova\Clients\", request.uploadFolder, request.FileName);

                using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    const int bufferLen = 65000;
                    byte[]    buffer    = new byte[bufferLen];
                    int       count     = 0;
                    while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
                    {
                        targetStream.Write(buffer, 0, count);
                    }
                    targetStream.Close();
                    sourceStream.Close();
                    return;
                }
            }
        }
Example #2
0
        public string GetDiskSize(Client client)
        {
            long   size = SizeInfo.GetSize(GetRootRepository(client));
            double gb   = Math.Round((size / Math.Pow(1024, 3)), 3);

            return("" + gb + " " + (1 - gb).ToString());
        }