question

codie-1009 avatar image
0 Votes"
codie-1009 asked karenpayneoregon answered

Add files as themes

Im making a program that manages skins for any game(or any other thing that supports themes, I just will call it game).
I cant seem to wrap my head around in coding this.

A example:
Random Game Files:
assets
----music
----level1.ogg
----level2.ogg
----level3.ogg
----level4.ogg
----level5.ogg
----levels
------level1.data
------level2.data
------level3.data
------level4.data
------level5.data
player.png
coin.png
coinget.ogg

Random Theme Files:
assets
----music
-----level3.ogg*[changed]
-----level1.ogg
[changed]
---player.png
[changed]
---coinget.ogg
[changed]
---aaa.png
[does not exist in base, ignore]
metadata.json
[metadata to make the skin have a custom display name in the app]*


How can I do this?
Thanks.

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

Hello,

Try the following (change the file extension as I don't have that type)

 Imports System
 Imports System.IO
 Public Class FileOperations
     Public Function GetRandomFile(ByVal path As String) As String
         Dim file As String = Nothing
         If Not String.IsNullOrEmpty(path) Then
             Dim extensions = New String() {".png"}
             Try
                 Dim di = New DirectoryInfo(path)
                 Dim fileInfo As IEnumerable(Of FileInfo) = di.GetFiles("*.*").Where(Function(f) extensions.Contains(f.Extension.ToLower()))
                 Dim R As New Random()
                 file = fileInfo.ElementAt(R.Next(0, fileInfo.Count())).FullName
             Catch
                 ' ignored
             End Try
         End If
         Return 
     End Function
 End Class
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.