Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1041055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:18:04+00:00 2026-05-16T15:18:04+00:00

I know this sounds backwards, but I have to convert this from C# to

  • 0

I know this sounds backwards, but I have to convert this from C# to Classic ASP. I don’t know any VBScript so I need help.

In my C# code, it is reading appkeys in the config file, parsing them, and using loops to perform a process. I don’t know how to do dictionaries and I/O stuff in VBScript. Can someone please help with this?

These are the keys which I guess I would have to store as constant variables in the .asp file:

<add key="Output.Size" value="550" />
<add key="Output.Ext" value=".jpg" />
<add key="Output.Folder" value="thumbs" />
<add key="Suffix.LG" value="750" />
<add key="Suffix.TN" value="250" />
<add key="Suffix.TNL" value="175" />
<add key="Suffix.TNR" value="75" />
<add key="Supported" value=".jpeg,.jpg,.gif,.bmp,.tiff,.png" />

This is the C# code:

Generate generate = new Generate();
generate.Process(source, destination); //inputs will be relative URL paths

    public class Generate
    {
        private const string OUTPUT_SIZE_KEY = "Output.Size";
        private const string OUTPUT_EXT_KEY = "Output.Ext";
        private const string SUFFIX_KEY = "Suffix.";
        private const string SUPPORTED_KEY = "Supported";
        private string[] supportedExt = null;

        public Generate()
        {
            //GET ALL SUPPORTED FORMAT TYPES TO PREVENT PROCESSING ON UNSUPPORTED FILES
            supportedExt = ConfigurationManager.AppSettings[SUPPORTED_KEY].ToLower().Split(',');
        }

        public void Process(string sourceDir, string destDir)
        {
            int thumbSize = Int32.Parse(ConfigurationManager.AppSettings[OUTPUT_SIZE_KEY]);
            string thumbExt = ConfigurationManager.AppSettings[OUTPUT_EXT_KEY];

            //COLLECT VALUES FOR RESIZING
            Dictionary<string, int> resizeValues = new Dictionary<string, int>();
            foreach (string item in ConfigurationManager.AppSettings.AllKeys)
            {
                if (item.StartsWith(SUFFIX_KEY))
                {
                    resizeValues.Add(item.Substring(SUFFIX_KEY.Length), Int32.Parse(ConfigurationManager.AppSettings[item]));
                }
            }

            //BEGIN GENERATING THUMBS
            foreach (string item in Directory.GetFiles(sourceDir))
            {
                //VALIDATE IF FILE TYPE SUPPORTED
                if (!supportedExt.Contains(Path.GetExtension(item.ToLower())))
                    continue;

                string fileName = Path.GetFileNameWithoutExtension(item);
                string outputFile = Path.Combine(destDir, fileName + thumbExt);

                //RESIZE TO THUMB
                Resize(item, outputFile, thumbSize); //DO NOT HAVE TO CONVERT "RESIZE"

                //RESIZE TO DIFFERENT THUMBS
                foreach (KeyValuePair<string, int> output in resizeValues)
                {
                    string thumbSeq = Path.Combine(destDir, fileName + output.Key + thumbExt);
                    Resize(item, thumbSeq, output.Value); //DO NOT HAVE TO CONVERT "RESIZE"
                }
            }
        }

UPDATE:
As suggested below, I converted to a VB for easier translation. It seems I have to rethink things as well. This is where I am but am getting an error:

<html>
<head>
    <title></title>
</head>
<body>
    <% 

    'DECLARE VARIABLES
Dim outputSize
Dim outputExt
Dim outputSuffix()
Dim supported
Dim source
Dim destination

'INITIALIZE VALUES
outputSize = 550
outputExt = ".jpg"
outputSuffix(0) = "LG.750"
outputSuffix(1) = "TN.250"
outputSuffix(2) = "TNL.175"
outputSuffix(3) = "TNR.75"
supported = ".jpeg,.jpg,.gif,.bmp,.tiff,.png"
source = "catalog/upload"
destination = "catalog"

'CALL FUNCTION TO RESIZE THUMBNAILS
Dim generate
generate = New ThumbGenerator
generate.Process source, destination

'PROCESS TO RESIZE
class ThumbGenerator
    Dim supportedExt

    Public Sub Process(sourceDir, destDir)
        Dim thumbSize
        Dim thumbExt
        thumbSize = outputSize
        thumbExt = outputExt
        supportedExt = supported.ToLower().Split(",")

        'COLLECT VALUES FOR RESIZING
        Dim resizeValues
        resizeValues = Dictionary(String, Integer)()
        For Each item As String In outputSuffix
            Dim temp
            temp = item.Split(".")
            resizeValues.Add(temp(0), temp(1))
        Next

        'BEGIN GENERATING THUMBS
        For Each item As String In Directory.GetFiles(sourceDir)
            'VALIDATE IF FILE TYPE SUPPORTED
            If Not supportedExt.Contains(Path.GetExtension(item.ToLower())) Then
                Continue For
            End If

            Dim fileName
            Dim outputFile
            fileName = Path.GetFileNameWithoutExtension(item)
            outputFile = Path.Combine(destDir, fileName + thumbExt)

            'RESIZE TO THUMB
            'Resize(item, outputFile, thumbSize)

            'RESIZE TO DIFFERENT THUMBS
            For Each output As KeyValuePair(Of String, Integer) In resizeValues
                Dim thumbSeq As String = Path.Combine(destDir, fileName + output.Key + thumbExt)
                'Resize(item, thumbSeq, output.Value)
            Next
        Next
    End Sub
End Class
    %>
</body>
</html>

This is the error I am getting:

Microsoft VBScript compilation error '800a03ea' 

Syntax error 

/sandbox/aspjpeg/Default.asp, line 45 

resizeValues = Dictionary(String, Integer)()
----------------------------------^
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:18:05+00:00Added an answer on May 16, 2026 at 3:18 pm

    (I won’t convert it for you but…)

    There exist several C# <-> VB.NET converters, e.g. http://converter.telerik.com/

    Once you have converted this to VB.NET it might be little bit easier to convert it to classic ASP / VBScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this sounds backwards but I would like to be able to determine
I know this sounds like a really obvious question, but it's proving harder to
I know this isn't strictly a programming question but y'all must have experienced this.
I know this sounds like a homework assignment, but it isn't. Lately I've been
I know this sounds bad but how can I disable/suppress a specific warning for
I know this sounds pretty trivial, but I'm new to jQuery... I use this
I know this sounds confusing: I have just built some basic prev/next pagination for
Does anyone know how to change the brush for a menu's background? This sounds
I know this question might sound a little cheesy but this is the first
I know this might be a no-brainer, but please read on. I also know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.