Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My.Computer errs

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
I'm building a class library of common/generic functions I'm going to use in my future projects. Some of them were already used in the projects made in VS 2012 - and worked.
One of them uses My.Computer in the project made in WinForms. Here's the code (part of the function that counts files in the given directory):
Code:
For Each lsFile As String In My.Computer.FileSystem.GetFiles(tsDir, lnSubDirs, lcFilePattern)
	lnCnt = lnCnt + 1
Next
I copy-pasted this function from that VS 2012 project into VS 2019 one... and it now gives me this error:

20220222_My_Computer_Errs_zxqx1r.jpg


Here's the imports list:
20220222_My_Computer_Errs_CommonSubsFincs_Imports_tt5had.jpg


I suspect that My exists only for a form, but I'm not sure. VS 2019 Help search didn't bring any relevant finds...

Q.: what am I missing?
Please advise.

Regards,

Ilya
 
Ilya said:
the function that counts files in the given directory

Code:
Imports System.IO
...
MessageBox.Show(Directory.GetFiles([blue]"C:\Temp\"[/blue], [blue]"*.txt"[/blue]).Count)

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
To Andrzejek: yes, the thought did occur. Thank you!

To SaltyTheFrog:
20220222_My_Computer_Errs_Suggested_Fix_ofhwyk.jpg


Regards,

Ilya
 
To StrongM: anything from .NET 1.0 and higher.

Regards,

Ilya
 
I don't mean, what frameworks are you hoping it will work on; I mean when you created the application what did you set as the target framework?

mynamespace_r2khlq.png
 
Class Library or Windows Application?

IUf the former, try switching it to Windows Application, compiling (which will fail), then switch it back to Class Library.

(make sure you have a backup of your program first though, just in case ... .Net 5 appears fussier about you doing this than previous versions.
 
To StrongM: yes, Class Library.
Actually, I went with what Andrzejek suggested.
But I will keep in mind this your suggestion, so - thank you!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top