'폴더'에 해당되는 글 2건

  1. 2021.05.09 윈도우10에 파일 공유 1
  2. 2017.10.28 [VBA]디렉토리 안의 파일 목록 구하기

윈도우10이 설치된 pc끼리 파일을 주고 받아야할때 usb, 이메일, 클라우드 서비스 등을 통해 할 수도 있지만

개인정보나 보안이 필요한 파일의 경우도 있습니다.

 

이경우 공유폴더를 설정하여 해결합니다.

1. 네트워크 및 공유센터-고급 공유 설정

(1) 개인: 네트워크 검색 켜기 + 자동설정 체크, 파일 및 프린터 공유 켜기

(2) 게스트 또는 공용: 네트워크 검색 켜기, 파일 및 프린터 공유 켜기

(3) 모든 네트워크: 공용 폴더 공유 켜기, 128비트 암호화 사용, 암호 보호 공유 끄기

 

2. 공유할 폴더-속성-공유

공유-Everyone 추가-공유(H)

 

3. 폴더 접근

(1) window키 + R: \\ip주소

예: \\192.168.0.16

 

더 상세한 정보는 하단 링크 참조.

 

※ 관련 링크(제목 클릭)

1. "[Windows] 윈도우10 공유 폴더 설정하기" (YJUN IT BLOG, 2020)

디렉토리(폴더)내의 파일 목록을 구하는 함수입니다.

다중선택은 안되고, 서브폴더까지 검색합니다.

ToDo: Target root 폴더에 파일이 없으면 종료되는 문제(서브디렉토리 파일 count까지 합하도록 변경 필요) -> 이부분 해결 방법 아시는 분은 댓글 남겨주시면 감사하겠습니다.

 

listFiles_v3.xls

 

내용은 다음과 같습니다.

'Force the explicit declaration of variables
Option Explicit

' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2017-Oct-28             Initial Release
' 2         2017-Oct-28             Enter the folder name
' 3         2017-Oct-29             Use File Dialog
' **************************************************************************************


Sub ListFiles()
     'Declare the variables
     Dim objFSO As FileSystemObject
     Dim objFolder As Folder
     Dim objFile As File
     Dim strPath As String
     Dim strFile As String
     Dim NextRow As Long
    
     'Added Codes Begin
     Dim Msg As String
    
     Call clearContents
    
     'Open the file dialog
     With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        If .Show = -1 Then
            'MsgBox (.SelectedItems(1))
            strPath = .SelectedItems(1)
        Else
            Exit Sub
        End If
     End With
 
    
     'Msg = "Write down the folder name, please: " & vbCr
     'Msg = Msg & "e.g. C:\Users\Steve\Documents\Vids\"
     'strPath = Trim(InputBox(Msg, "Input"))
 
     If right(strPath, 1) <> "\" Then strPath = strPath & "\"
    
     'Added Codes End
    
     'Create an instance of the FileSystemObject
     Set objFSO = CreateObject("Scripting.FileSystemObject")
    
     'Get the folder
     Set objFolder = objFSO.GetFolder(strPath)
    
     'If the folder does not contain files, exit the sub
     If objFolder.Files.Count = 0 Then
         MsgBox "No files were found...", vbExclamation
         Exit Sub
     End If
    
     'Turn off screen updating
     Application.ScreenUpdating = False
    
     'Insert the headers for Columns A, B, and C
     Cells(1, "A").Value = "FileName"
     Cells(1, "B").Value = "Path"
     Cells(1, "C").Value = "Size"
    
     'Find the next available row
     NextRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
    
     'Loop through each file in the folder
     For Each objFile In objFolder.Files
    
         'List the name, size, and date/time of the current file
         Cells(NextRow, 1).Value = objFile.Name
         Cells(NextRow, 2).Value = objFile.Path
         Cells(NextRow, 3).Value = objFile.Size
        
         'Determine the next row
         NextRow = NextRow + 1
    
     Next objFile
    
     'Change the width of the columns to achieve the best fit
     'Columns.AutoFit
    
     'Turn screen updating back on
     Application.ScreenUpdating = True
        
End Sub

Sub clearContents()
    Worksheets("List").Range("A1").EntireColumn.EntireRow.clearContents
End Sub

 

1 

글 보관함

카운터

Total : / Today : / Yesterday :
get rsstistory!