how to calculate "C drive" Free space

VJR

Well-Known Member
Hi Anjaneyareddy,

This will involve writing a Code stage in whichever language you prefer that is supported by Blue Prism (VB, C#, J#).

If you are looking for C# code you can refer to @dtkubal's post here.

If you are looking for VB code then it is as below.

Code:
    Dim Drv As Object
    Dim fs As Object
    Dim Letter As String

    fs = CreateObject("Scripting.FileSystemObject")
    Drv = fs.GetDrive(fs.GetDriveName("C:\"))

    Letter = Drv.DriveLetter

    TotalSpace = Drv.TotalSize
    FreeSpace = Drv.FreeSpace

    'Convert in GB:
    '1073741824 B = 1 GB
    'Fix returns the integer portion of a number

    TotalSpace = Fix(TotalSpace / 1073741824)
    FreeSpace = Fix(FreeSpace / 1073741824)


Remember to add Microsoft.VisualBasic to the namespace in the Initialise tab.

Add these as Output parameters to the Code stage.
1527613017667.png

After running the code you will receive the values in GB in their respective data items.
1527613093833.png

You will need to modify the code as per your requirement. For eg; you need to check if the drive exists, pass the drive as parameter to the Object and then to the Code stage, if needed convert to Terabyte, etc.
 

Anjaneyareddy

New Member
hii vjr,

after adding the same above code and process also no errors in the code stage.

but
in object validation page it shows 2 errors
Page: Initialise
Stage: Stage1
Type: Error
Action: Validate
Description: Compiler error at top section line -5: compiler initialization failed unexpectedly: The system cannot find the file specified.
Repairable: No

and
InitialiseStage1ErrorValidateCompiler error at top section line -5: could not find library 'Microsoft.VisualBasic'No

and i added the NameSpace in codeoption in the Initialize page
 

Attachments

  • Screenshot.jpg
    Screenshot.jpg
    28 KB · Views: 13

VJR

Well-Known Member
Hi Anjaneyareddy,

Appears that your machine may have registration issues with the Microsoft.VisualBasic dll
Or check if it is present at all?
It is usually in the .Net framework folder like - C:\Windows\Microsoft.NET\Framework\

All I can suggest you to is to research on that 'not found library' error message
Below is a good start. I do not know if the solutions given there would work but I'm just giving you a reference in some direction.
How To Fix Microsoft.VisualBasic.dll Errors:
https://www.solvusoft.com/en/files/...rosoft-silverlight/microsoft-visualbasic-dll/
Do remember to take a look at the different Caution sections on the webpage.
 
Top