Answered by:
Count words in the ascx file

Question
-
User1167928869 posted
Hello!
I have 163 .resx files. I want to count the words in these files, because my want to translate the sentences (my task is the localisation).
Now I'm opening each file in Ms Visual Studio and I count words manually. How can I count words in all files? And the second question: can I use a program what grab strings from .resx into an editor where I can translate them and save bacn into .resx files? Or must open the files one by one and edit the text fields manually?
Thanks for helping, unfortunately I'm not a programmer.
Sunday, August 15, 2010 2:20 PM
Answers
-
User-242433875 posted
Hi,
Below is given the code using which you can read all the content of a particular file and find the character count. You can later expand this snippet to find the total number of characters in all files inside a particular folder (in your scenario, which may be App_GlobalResources).
Imports System Imports System.IO Module Module1 Sub Main() Try ' Create an instance of FileStream to read from a file. Dim fs As New FileStream("c:\TestFile.txt", FileMode.Open, FileAccess.Read) ' Create an instance of StramReader to read the file's content Dim sr As StreamReader = New StreamReader(fs) Dim text As String 'Setting pointer at beginning of file sr.BaseStream.Seek(0, SeekOrigin.Begin) text = sr.ReadToEnd() Dim FileLength As Long = text.Length 'Holds the total number of characters, number and symbols in file Console.Write(text.Length) 'Writes the length of file content on Console sr.Close() 'Closing StreamReader fs.Close() 'Closing FileStream Catch E As Exception ' Let the user know what went wrong. Console.WriteLine("The file could not be read:") Console.WriteLine(E.Message) End Try Console.ReadKey() End Sub End Module
If you need further help, let me know.- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, August 17, 2010 10:10 AM
All replies
-
User1167928869 posted
Nobody can't help me?
Tuesday, August 17, 2010 6:41 AM -
User-1327195235 posted
hi,
you can count no. of words by simply copying all the text from .resx file to a word file, and then using 'word count' utility in the MS word.
Tuesday, August 17, 2010 6:48 AM -
User1167928869 posted
Thanks,
but unfortunately I have 163 file and 2-20 strings in each file. It's a big work I just want to know if an easier way is available.
Tuesday, August 17, 2010 7:20 AM -
User-242433875 posted
Hi,
Below is given the code using which you can read all the content of a particular file and find the character count. You can later expand this snippet to find the total number of characters in all files inside a particular folder (in your scenario, which may be App_GlobalResources).
Imports System Imports System.IO Module Module1 Sub Main() Try ' Create an instance of FileStream to read from a file. Dim fs As New FileStream("c:\TestFile.txt", FileMode.Open, FileAccess.Read) ' Create an instance of StramReader to read the file's content Dim sr As StreamReader = New StreamReader(fs) Dim text As String 'Setting pointer at beginning of file sr.BaseStream.Seek(0, SeekOrigin.Begin) text = sr.ReadToEnd() Dim FileLength As Long = text.Length 'Holds the total number of characters, number and symbols in file Console.Write(text.Length) 'Writes the length of file content on Console sr.Close() 'Closing StreamReader fs.Close() 'Closing FileStream Catch E As Exception ' Let the user know what went wrong. Console.WriteLine("The file could not be read:") Console.WriteLine(E.Message) End Try Console.ReadKey() End Sub End Module
If you need further help, let me know.- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, August 17, 2010 10:10 AM