How to get the String Length of file's name?

Dear all ,

i have a quesiton wanna to solve it .

how could i get the string length of file’s name ? if the string length of file’s name is more than 20 string, move this file .

anybody could help me ? thanks a lot in advance .

To get the filename, pass a path MyPath as a string to System.IO.Path.GetFileName(MyPath), which you can assign to MyFile to get the filename into a variable.

You can check the length of a string using MyFile.Length, where MyFile is the string whose length you want to check.

Create an If activity to check the length, and if the length is greater than 20 characters, use a Move File activity to move the file.

1 Like

how to change the string length to Byte length?

They are one in the same. A single character takes up one byte of space.

bytecount = System.Text.Encoding.Default.GetBytecount(yourFileName)
String_length and Byte_count are different in Korean, Chinese, Japanese.
A single character of them contains 2bytes, but length of them is 1