Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,090 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,813 people online right now. Registration is fast and FREE... Join Now!




user has file open so i cant access it

 
Reply to this topicStart new topic

user has file open so i cant access it

keithmoloney
9 May, 2008 - 11:22 AM
Post #1

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 33



Thanked: 1 times
My Contributions
CODE

For Each lbfile As IO.FileInfo In diar3
                            Dim itemlb1 As String = item.FullName
                            Dim itemlb As String = Path.GetFileNameWithoutExtension(itemlb1)
                            Dim lbfile1 As String = lbfile.FullName
                            'copy the appropriate .lb file
                            If lbfile.FullName.Contains(itemlb) Then
                                'make sure it is a .lb file and then release
                                If lbfile.Extension = ".lb" Then
                                    Try
                                        File.Copy(lbfile1, DEST_LIB + "\" + lbfile.Name, True)
                                        'add to the email
                                        strEmail = strEmail + Environment.NewLine + Path.GetFileName(lbfile1)
                                    Catch e As
                                        'inform of files not copied
                                        strEmail = strEmail + Environment.NewLine + "File could not be copied: " + Path.GetFileName(lbfile1)
                                    End Try
                                End If
                            End If

                        Next


my try catch block tries to copy a file, if a user has it open, it will obviously be unable to do so. if this is the case, it adds a line to my confirmation email saying that the file could not be copied. i want to add the name of the user who is preventing this operation to also be added to the email. i think i probably need to use the system.environment.username? well not exactly but something similar? just not sure how.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:02AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month