<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zaw</title>
    <description>The latest articles on DEV Community by Zaw (@zawhtut).</description>
    <link>https://dev.to/zawhtut</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F287371%2F9faf9294-62a3-44b4-a819-8a8a6d460ab1.jpg</url>
      <title>DEV Community: Zaw</title>
      <link>https://dev.to/zawhtut</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zawhtut"/>
    <language>en</language>
    <item>
      <title>The best method to save a clean web page online...</title>
      <dc:creator>Zaw</dc:creator>
      <pubDate>Sun, 29 Sep 2024 00:40:23 +0000</pubDate>
      <link>https://dev.to/zawhtut/the-best-method-to-save-a-clean-web-page-online-np6</link>
      <guid>https://dev.to/zawhtut/the-best-method-to-save-a-clean-web-page-online-np6</guid>
      <description>&lt;p&gt;Are you looking for a way to save a web page without all the unnecessary graphics and ads? If you're using the Edge browser, here's the best method to do just that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step One.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Open a web page in the Edge browser and click the icon with the &lt;code&gt;open-book-speaker&lt;/code&gt; symbol.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z0knt3m6p3i8q6d7y0l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9z0knt3m6p3i8q6d7y0l.png" alt="The original web page with all its content and ads before applying the reading mode in Edge." width="596" height="676"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Caption: The original web page with all its content and ads before applying the reading mode in Edge.&lt;/em&gt;
&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxgnnej18rhihkidajdc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxgnnej18rhihkidajdc.png" alt="The web page in Edge's reading mode, showing a clean version without ads or unnecessary graphics." width="619" height="717"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Caption: The web page in Edge's reading mode, showing a clean version without ads or unnecessary graphics.&lt;/em&gt;
&lt;/h6&gt;

&lt;h2&gt;
  
  
  Step Two.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Click &lt;code&gt;Print&lt;/code&gt; to save the page as a printed copy or a PDF. Alternatively, click &lt;code&gt;Save Page As...&lt;/code&gt; to save it as an HTML file.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyd75j92rke4ianxycp1n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyd75j92rke4ianxycp1n.png" alt="Access the " width="685" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  &lt;em&gt;Caption: Access the "Print" option or use "Save Page As..." from the Edge browser’s menu for saving a cleaner version of the web page.&lt;/em&gt;
&lt;/h6&gt;

&lt;h3&gt;
  
  
  To Learn ML.NET:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.todaysoftmag.com/article/3286/machine-learning-101-with-microsoft-ml-net-part-1-3" rel="noopener noreferrer"&gt;https://www.todaysoftmag.com/article/3286/machine-learning-101-with-microsoft-ml-net-part-1-3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.todaysoftmag.com/article/3290/machine-learning-101-with-microsoft-ml-net-part-2-3" rel="noopener noreferrer"&gt;https://www.todaysoftmag.com/article/3290/machine-learning-101-with-microsoft-ml-net-part-2-3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.todaysoftmag.com/article/3293/machine-learning-101-with-microsoft-ml-net-part-3-3" rel="noopener noreferrer"&gt;https://www.todaysoftmag.com/article/3293/machine-learning-101-with-microsoft-ml-net-part-3-3&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>edgebrowser</category>
      <category>readermode</category>
      <category>immersivereader</category>
      <category>browser</category>
    </item>
    <item>
      <title>Deconstructing Search Input Box on Fluent UI's Demo Website…</title>
      <dc:creator>Zaw</dc:creator>
      <pubDate>Wed, 12 Jun 2024 00:40:43 +0000</pubDate>
      <link>https://dev.to/zawhtut/deconstructing-search-input-box-on-fluent-uis-demo-website-4nho</link>
      <guid>https://dev.to/zawhtut/deconstructing-search-input-box-on-fluent-uis-demo-website-4nho</guid>
      <description>&lt;p&gt;The search box component that we see on the demo website is actually implemented using &lt;code&gt;FluentAutocomplete&lt;/code&gt;. This component combines a text box and a drop-down list box to provide autocomplete functionality.&lt;/p&gt;

&lt;p&gt;I want to share my insights on how the &lt;code&gt;FluentAutocomplete&lt;/code&gt; is implemented on FluentUI's demo website. This will enable us to implement or customize it ourselves. By understanding the underlying structure and functionality, we can tailor the &lt;code&gt;FluentAutocomplete&lt;/code&gt; to better suit our specific needs and enhance our applications.&lt;/p&gt;

&lt;p&gt;Blazor is a web framework that allows C# and .NET developers to create interactive web apps. It enables developers to create rich, modern web applications with a combination of C# code, HTML, and CSS, without relying heavily on JavaScript.&lt;/p&gt;

&lt;p&gt;Autocomplete is a feature commonly found in user interfaces that provides suggestions to the user as they type, helping them complete their input more quickly and accurately. In the context of web development, an autocomplete component typically combines a text input field with a dropdown list that displays suggested options based on the user's input.&lt;/p&gt;

&lt;p&gt;First, let's navigate to the &lt;code&gt;Shared&lt;/code&gt; folder in FluentUI's GitHub repository.&lt;/p&gt;

&lt;p&gt;You can find the repository here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/microsoft/fluentui-blazor/tree/dev/examples/Demo/Shared/Shared
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we need to locate the search box component in the &lt;code&gt;DemoMainLayout.razor&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="search"&amp;gt;
    &amp;lt;DemoSearch /&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;DemoSearch&lt;/code&gt; element is a Blazor web component implemented in the &lt;code&gt;DemoSearch.razor&lt;/code&gt; file. By Blazor's convention, the name of the Razor file becomes the component name, allowing it to be used like an HTML tag.&lt;/p&gt;

&lt;p&gt;The following code block &lt;code&gt;FluentAutocomplete&lt;/code&gt; is implemented in &lt;code&gt;DemoSearch.razor&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;FluentAutocomplete TOption="NavItem"
                    Width="200px"
                    AutoComplete="off"
                    Placeholder="Search everything..."
                    MaximumSelectedOptions="1"
                    OptionText="@(item =&amp;gt; item.Title)"
                    @bind-ValueText="@_searchTerm"
                    @bind-SelectedOptions="_selectedOptions"
                    @bind-SelectedOptions:after="HandleSearchClicked"
                    OnOptionsSearch="@HandleSearchInput"
                    ShowOverlayOnEmptyResults="false"&amp;gt;
    &amp;lt;OptionTemplate&amp;gt;
        &amp;lt;span slot="start"&amp;gt;
            &amp;lt;FluentIcon Value="@(context.Icon)" Class="search-result-icon" Color="Color.Neutral" Slot="start"/&amp;gt;
        &amp;lt;/span&amp;gt;
        @context.Title
    &amp;lt;/OptionTemplate&amp;gt;
&amp;lt;/FluentAutocomplete&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, &lt;code&gt;TOption&lt;/code&gt; is a generic type parameter representing the type of options that the &lt;code&gt;&amp;lt;FluentAutocomplete&amp;gt;&lt;/code&gt; component will operate on. In this case, it will be working with the &lt;code&gt;NavItem&lt;/code&gt; class, which is defined in &lt;code&gt;NavItem.cs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Width="200px"&lt;/code&gt; : Sets the width of the search box.&lt;br&gt;
&lt;code&gt;AutoComplete="off"&lt;/code&gt; : Disables autocomplete in the input field.&lt;br&gt;
&lt;code&gt;Placeholder="Search everything..."&lt;/code&gt; : Sets the placeholder text.&lt;br&gt;
&lt;code&gt;MaximumSelectedOptions="1"&lt;/code&gt; : Limits the number of selectable options to 1.&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;NavItem&lt;/code&gt; is used as &lt;code&gt;TOption&lt;/code&gt;, we can specify &lt;code&gt;OptionText&lt;/code&gt; using the &lt;code&gt;Title&lt;/code&gt; property of &lt;code&gt;NavItem&lt;/code&gt;. This property is used to display for each &lt;code&gt;NavItem&lt;/code&gt; in the dropdown list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@bind-ValueText="@_searchTerm"
@bind-SelectedOptions="_selectedOptions"
@bind-SelectedOptions:after="HandleSearchClicked"
OnOptionsSearch="@HandleSearchInput"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code block within the  component is responsible for establishing data bindings with the methods it will call.&lt;/p&gt;

&lt;p&gt;In a Blazor component, C# code is typically written within a &lt;code&gt;@code { }&lt;/code&gt; block using the &lt;code&gt;@code&lt;/code&gt; directive. Alternatively, code can be placed in a separate code-behind &lt;code&gt;.cs&lt;/code&gt; file. By convention, the code-behind file should have the same name as the Razor file with a &lt;code&gt;.razor.cs&lt;/code&gt; extension, such as &lt;code&gt;MyComponent.razor.cs&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Therefore, we can find the &lt;code&gt;DemoSearch.razor&lt;/code&gt;'s C# code in &lt;code&gt;DemoSearch.razor.cs&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This code &lt;code&gt;@bind-ValueText="@_searchTerm"&lt;/code&gt; will bind the value of the text box to the &lt;code&gt;_searchTerm&lt;/code&gt;. On the other hand, this &lt;code&gt;@bind-SelectedOptions="_selectedOptions"&lt;/code&gt; will just set &lt;code&gt;_selectedOptions&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Lastly, &lt;code&gt;OnOptionsSearch&lt;/code&gt; event is an &lt;code&gt;EventCallback&amp;lt;OptionsSearchEventArgs&amp;lt;TOption&amp;gt;&amp;gt;&lt;/code&gt; that is used to filter the list of options based on the text input by the user. &lt;code&gt;EventCallBack&lt;/code&gt; is a generic type that allows passing event data to a method in the component. By setting &lt;code&gt;OnOptionsSearch="@HandleSearchInput"&lt;/code&gt;, we specify that the &lt;code&gt;HandleSearchInput&lt;/code&gt; method will handle the filtering logic. This method processes the user's input and updates the list of options accordingly. We can see these code implementations in &lt;code&gt;DemoSearch.razor.cs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This should now provide a clear and coherent explanation of how the &lt;code&gt;FluentAutocomplete&lt;/code&gt; component is implemented and how it works.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;FluentAutocomplete&lt;/code&gt; component is part of the FluentUI Blazor library, which provides a range of UI components designed for Blazor applications. You can explore more about FluentUI Blazor &lt;a href="https://www.fluentui-blazor.net/Autocomplete"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.fluentui-blazor.net/"&gt;FluentUI Blazor Official Website&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blazor</category>
      <category>fluentui</category>
      <category>searchbox</category>
      <category>autocomplete</category>
    </item>
    <item>
      <title>My experience with installing nopCommerce on Azure</title>
      <dc:creator>Zaw</dc:creator>
      <pubDate>Wed, 13 Jul 2022 22:16:01 +0000</pubDate>
      <link>https://dev.to/zawhtut/my-experience-of-installing-nopcommerce-on-azure-2i49</link>
      <guid>https://dev.to/zawhtut/my-experience-of-installing-nopcommerce-on-azure-2i49</guid>
      <description>&lt;p&gt;Since I have an affinity with C# and &lt;a href="https://dotnet.microsoft.com/en-us/learn/dotnet/what-is-dotnet"&gt;.NET&lt;/a&gt;, I wanted to try nopCommerce. nopCommerce is an open source e-commerce solution based on .NET technology. Before you set up nopCommerce on Azure, if you have a custom domain to use, make sure you have a SSL certificate for that domain. And then you create an Azure Web App service. You can follow this &lt;a href="https://docs.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore?tabs=net60&amp;amp;pivots=development-environment-azure-portal"&gt;tutorial&lt;/a&gt; to lay a ground foundation for ASP.NET app on Azure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creation of Azure App Service Plan and SQL Database
&lt;/h2&gt;

&lt;p&gt;At first, you might want to choose the B1 app service plan. Though it is a higher price, you just need it for set-up time. For experimental purpose development, you can scale down to F1 or D1 service plan after installation to use nopCommerce for almost free of charge. After creating the app plan, you can associate it with your &lt;a href="https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain"&gt;custom domain&lt;/a&gt;. You will still need B1 or higher app service plans to use custom domain and SSL. Otherwise, you can still use Azure's subdomain &lt;code&gt;{app_name}.azurewebsites.net&lt;/code&gt; that comes with &lt;code&gt;HTTPS&lt;/code&gt;. After that, you will need to create a SQL database service for the app. So there are service tiers that suit your app's demands. For my app, I just chose the purchasing model as &lt;code&gt;DTU&lt;/code&gt; and the service tier as &lt;code&gt;basic tier&lt;/code&gt;, which comes with a maximum of 5 &lt;a href="https://docs.microsoft.com/en-us/azure/azure-sql/database/service-tiers-dtu"&gt;DTU&lt;/a&gt; and 2GB of storage. That is about $5 per month, which is the lowest pricing for using &lt;a href="https://docs.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&amp;amp;tabs=azure-portal"&gt;Azure SQL Database&lt;/a&gt;. After the creation, you should also configure the SQL server &lt;a href="https://docs.microsoft.com/en-us/azure/azure-sql/database/firewall-create-server-level-portal-quickstart?view=azuresql"&gt;firewall setting&lt;/a&gt; in the SQL Azure Portal under security and networking. You can set it as public access but only with selected networks with the IP address of the app and the IP addresses of development machines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment of nopCommerce app
&lt;/h2&gt;

&lt;p&gt;There are two ways to deploy the app on Azure. I don't find nopCommerce in the Azure app gallery as of now though. So I have tried FTP deployment and app publishing from Visual Studio. The best way is to publish it from Visual Studio. FTP deployment takes too long to transfer files to Azure. That may be due to the app service plan, which has basic hardware performance. But the file transfer is quicker with the Visual Studio deployment. I can either clone the app from nopCommerce's &lt;a href="https://github.com/nopSolutions/nopCommerce/"&gt;GitHub site&lt;/a&gt; or download it from &lt;a href="https://github.com/nopSolutions/nopCommerce/releases"&gt;releases&lt;/a&gt; to do &lt;a href="https://docs.microsoft.com/en-us/azure/app-service/deploy-ftp?tabs=portal"&gt;FTP deployment&lt;/a&gt;. To publish from Visual Studio, I need to download &lt;a href="https://docs.microsoft.com/en-us/visualstudio/azure/how-to-get-publish-profile-from-azure-app-service"&gt;publish profile&lt;/a&gt; from Azure App Service. In Visual Studio, when you publish the app, you can just &lt;a href="https://docs.microsoft.com/en-us/visualstudio/deployment/deploying-applications-services-and-components-resources?view=vs-2022#import-profile"&gt;import&lt;/a&gt; the publish profile that you downloaded from Azure app service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up nopCommerce after Publishing or FTP.
&lt;/h2&gt;

&lt;p&gt;Before you set up nopCommerce, make sure you start from your custom domain. If you don't have a custom domain, make sure HTTPS is turn on with Azure's subdomain in Azure App setting. Sometimes there may be connection time out during setup. So you can set &lt;code&gt;Connect Timeout = 120&lt;/code&gt; or so in SQL connection string. If something goes wrong, I have to delete the database catalog in Azure SQL and files under &lt;code&gt;C:\home\site\wwwroot\&lt;/code&gt; in web app because nopCommerce's Reinstall feature doesn't reset or delete the setting files to reinstall (I'll submit GitHub issue with that). The following PowerShell command is useful to remove files in the web app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Remove-Item * -Recurse -Force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can access PowerShell prompt for Azure web app via App Service's Advanced Tools under Development Tools and click the link &lt;code&gt;Go&lt;/code&gt;. If you need to access the database stand-alone, you can use &lt;a href="https://docs.microsoft.com/en-us/sql/azure-data-studio/what-is-azure-data-studio"&gt;Azure Data Studio&lt;/a&gt; or Azure Portal's &lt;a href="https://docs.microsoft.com/en-us/azure/azure-sql/database/connect-query-portal?view=azuresql#connect-to-the-query-editor"&gt;SQL Query Editor&lt;/a&gt;. During my nopCommerce installation, I mixed up custom domain and Azure's subdomain. I shouldn't install under Azure's subdomain and access the site with custom domain. With that issue, the domain was inaccessible and I had to manually change the domain in setting table &lt;code&gt;dbo.Setting&lt;/code&gt; in the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It was a good experience using Azure App Service and Azure SQL Database. I learnt how to scale up or down web app and how to set up Azure SQL database. Azure App instances and SQL Database service tiers except &lt;code&gt;Basic&lt;/code&gt; one can raise the cost of running services significantly. It could reach several hundred dollars in a month. Even when my website hasn't been launched or no one is accessing the site, there are automatic app activities or Azure's services running in the background. That could also raise the cost too high. I had tried to use SQL server on my Windows VM which is also hosted on Azure. It was not viable. Currently, I scale back the app to F1 free app service and basic Azure SQL database.&lt;/p&gt;

</description>
      <category>nopcommerce</category>
      <category>azure</category>
      <category>azuresql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Converting PNG to JPG image files in C#</title>
      <dc:creator>Zaw</dc:creator>
      <pubDate>Sun, 08 Dec 2019 01:03:19 +0000</pubDate>
      <link>https://dev.to/zawhtut/converting-png-to-jpg-image-files-in-c-4f3j</link>
      <guid>https://dev.to/zawhtut/converting-png-to-jpg-image-files-in-c-4f3j</guid>
      <description>&lt;p&gt;If you are a programmer and you have hundreds of &lt;em&gt;PNG&lt;/em&gt; files occupying your storage disk, you can save some space by converting &lt;em&gt;PNG&lt;/em&gt; to &lt;em&gt;JPG&lt;/em&gt; files, provided that you're not concerned about reducing some non-visible quality.&lt;/p&gt;

&lt;p&gt;Here are the steps you can code that program in C#.&lt;/p&gt;

&lt;p&gt;In bash/console terminal,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt; &lt;span class="n"&gt;png2jpg&lt;/span&gt;
&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;png2jpg&lt;/span&gt;
&lt;span class="n"&gt;dotnet&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;console&lt;/span&gt;
&lt;span class="n"&gt;dotnet&lt;/span&gt; &lt;span class="k"&gt;add&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Drawing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Common&lt;/span&gt;
&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add new &lt;em&gt;using&lt;/em&gt; statements in &lt;em&gt;Program.cs&lt;/em&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.IO&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Drawing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Drawing.Imaging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following code in &lt;em&gt;main&lt;/em&gt; program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;folder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"/Users/PNGs/"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;Directory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetFiles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;ext&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetExtension&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ToLower&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ext&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;".png"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetFileNameWithoutExtension&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetDirectoryName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                    &lt;span class="n"&gt;Image&lt;/span&gt; &lt;span class="n"&gt;png&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                    &lt;span class="n"&gt;png&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;@"/"&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;".jpg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ImageFormat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Jpeg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="n"&gt;png&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

                    &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;++;&lt;/span&gt;
                    &lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{0} file(s) converted."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Press any key to exit."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReadLine&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this code does is it will get the path to the &lt;em&gt;PNG&lt;/em&gt; directory. It will check the files one by one whether it has a &lt;em&gt;PNG&lt;/em&gt; extension. When the &lt;em&gt;PNG&lt;/em&gt; file is found, it will split the name and the path of that file. And save the file with the extension, &lt;em&gt;JPG&lt;/em&gt; and its format. Then it will finalize the image and &lt;strong&gt;delete&lt;/strong&gt; the &lt;em&gt;PNG&lt;/em&gt; accordingly.&lt;/p&gt;

&lt;p&gt;If you are using &lt;em&gt;macOS&lt;/em&gt;, you may need to install &lt;code&gt;mono-libgdiplus&lt;/code&gt;. If I've missed some &lt;em&gt;Exception Handling&lt;/em&gt;, please let me know. Thanks for reading.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
