2

Background: We use a SQLCE database in our Windows application. Some users will choose to store this database on a network for easy sharing between users (not simultaneously). When the database is opened on a network drive we want to copy the database to a local folder for better performance and back when the application closes. The reason for this is that on some networks, the performance is simply unacceptable (and yeah, the user shouldn't place the database there, but they do).

Our current detection of a network file is simply using DriveInfo and DriveType == DriveType.Network, but this also catches local folders mapped to a drive and other similar scenarios (reported back from users). Is there a better way to really detect if a file is on a network or even better any kind of slow connection (the later will probably require some kind of measured reading of a big file, which we are not really interested in doing, so we'll settle for the first part)? I don't think .Net directly supports this, but a P/Invoke is just as good.

Thanks in advance.

rebel
  • 85
  • 1
  • 6
  • Note that network doesn't necessarily equal slow connection, any more than local storage equals fast connection (e.g. low-grade Flash storage can be an order of magnitude slower than a network link). – Piskvor left the building Jan 03 '12 at 09:25
  • You might want to check out this [link][1]. [1]: http://stackoverflow.com/questions/458363/determining-if-file-exists-using-c-sharp-and-resolving-unc-path – Kristianne Nerona Jan 03 '12 at 09:46
  • Okay, a network connection can be faster, but that is usually not the case and it is not what our users are reporting. We are happy if we can cater to the majority of users which we believe is possible if we can find a better way to determine when a file is residing on a "real" network. – rebel Jan 03 '12 at 11:20
  • I can't see what the suggested link have to do with our problem, so please clarify. – rebel Jan 03 '12 at 11:21

1 Answers1

0

See http://www.pinvoke.net/default.aspx/kernel32.getdrivetype

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • Tested it and it returns the same value as DriveInfo, so there is no advantage to using it – rebel Jan 04 '12 at 10:18