Retrieve FileID from DotNetNuke using FileName

后端 未结 1 437
迷失自我
迷失自我 2021-01-26 12:03

I\'m trying to get the FileID of a file based on the FileName. This is what I have, but it returns false. Any ideas?

  Dim oFileInfo As New DotNetNuke.Services.F         


        
相关标签:
1条回答
  • 2021-01-26 12:24

    I suggest you something like that:

        Dim oFileInfo As New DotNetNuke.Services.FileSystem.FileInfo
    
        Dim FileID As Integer
    
        Dim oFolderInfo As New DotNetNuke.Services.FileSystem.FolderInfo
        If FolderManager.Instance.FolderExists(PortalId, "uploads/files/") Then
            oFolderInfo = FolderManager.Instance.GetFolder(PortalId, "uploads/files/")
            If FileManager.Instance.FileExists(oFolderInfo, "4secapplication.PNG") = True Then
                oFileInfo = FileManager.Instance.GetFile(oFolderInfo, "4secapplication.PNG")
                FileID = oFileInfo.FileId
            Else
                lblExceptions.Text = "not exists"
            End If
    
        End If
    

    Or a shortest method:

        Dim oFileInfo As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(PortalId, "uploads/files/4secapplication.PNG")
    
        Dim FileID As Integer
    
        If oFileInfo IsNot Nothing Then
            FileID = oFileInfo.FileId
        Else
            lblExceptions.Text = "not exists"
        End If
    
    0 讨论(0)
提交回复
热议问题