Use MaxFileSize With Openfile Common Dialogs

Use MaxFileSize With Openfile Common Dialogs

When working with OpenFile common dialogs, set a large value for the MaxFileSize property, which affects the maximum length of the string returned in the FileName property. This is the string containing the names of all the files selected by the user. For example, you can reserve 10 kilobytes for this string by executing this statement before showing the dialog:

 CommonDialog1.MaxFileSize = 10240

The returned string’s format depends on how many files the user selects. If the user selects only one file, the string returns in the FileName property that contains the complete name of this file (path + name). If the user selects multiple files, the returned value contains the directory name, followed by all the names without the path. If you use the cdlOFNExplorer flag, the separator character is the Null character. If you’re using VB6, you can use the Split function to quickly parse the returned value:

 CommonDialog1.Filter = "All files (*.*)|*.*"CommonDialog1.FilterIndex = 1CommonDialog1.Flags = cdlOFNAllowMultiselect Or _	cdlOFNFileMustExist Or cdlOFNExplorerCommonDialog1.MaxFileSize = 10240CommonDialog1.CancelError = TrueCommonDialog1.Filename = ""CommonDialog1.ShowOpenIf Err = 0 Then	' Parse the result into an array of strings	Dim names() As String, i As Integer	names() = Split(CommonDialog1.Filename, vbNullChar)	' Print file names, including path	If UBound(names) = 0 Then		' only one file was selected		Print names(0)	Else		' multiple files were selected		For i = 1 To UBound(names)			Print names(0) & "" & names(i)		Next	End IfEnd If
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes