Help in converting vb.net function to C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nurcky
    New Member
    • Jul 2012
    • 1

    Help in converting vb.net function to C#.net

    I need help converting vb.net code to c#. here it is.

    Code:
        'Get the ID File Type from file path name
        Public Function GetFileType(ByVal fileName As String) As EFile
            Dim i As Integer
            For i = 0 To SFile
                If InStr(1, fileName, VTFile(i).fileExt) = Len(fileName) - Len(VTFile(i).fileExt) + 1 Then
                    GetFileType = VTFile(i).fileID
                    Exit Function
                End If
            Next
            GetFileType = EFile.NOTDEF
        End Function
    **Edited:**

    This is what i got so far in C#
    Code:
            //Get the ID File Type from file path name
            public EFile GetFileType(string fileName)
            {
                EFile functionReturnValue = default(EFile);
                int i = 0;
                for (i = 0; i <= SFile; i++)
                {
                    if (Strings.InStr(1, fileName, VTFile[i].fileExt) == Strings.Len(fileName) - Strings.Len(VTFile[i].fileExt) + 1)
                    {
                        functionReturnValue = VTFile[i].fileID;
                        return functionReturnValue;
                    }
                }
                functionReturnValue = EFile.NOTDEF;
                return functionReturnValue;
            }
    i get errors at this line:
    Code:
        if (Strings.InStr(1, fileName, VTFile[i].fileExt) == Strings.Len(fileName) - Strings.Len(VTFile[i].fileExt) + 1)
    its complaining of "Strings.IpStr( )" and "Strings.Len()" .
    Error code:The name 'Strings' does not exist in the current context.

    thanks in advance
Working...