How to Get the Working Directory in a WPF Project

Yesterday, my colleague told me that there was a weird issue that existed in our WPF sample code for Dynamic .NET TWAIN. What we wanted to implement was to create two projects, and start one application from another. The problem was, when we started the invoked application independently, it worked well. Whereas when it was invoked from another application, none of the UI resources loaded.

ImageBrush dpTitle.Background = new ImageBrush(new BitmapImage(new Uri(imageDirectory + "title.png", UriKind.RelativeOrAbsolute))); // Loading UI resources

Because of this behavior, I thought the resource path might be wrong. After I investigated the source code, I found that our developer used the Property Environment.CurrentDirectory.

Here is the code:

String imageDirectory = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("Samples")) + @"Samples\Bin\Images\WpfDemoImages\";

Refering to Microsoft’s remarks “By definition, if this process starts in the root directory of a local or network drive, the value of this property is the drive name followed by a trailing slash (for example, “C:\”). If this process starts in a subdirectory, the value of this property is the drive and subdirectory path, without a trailing slash (for example, “C:\mySubDirectory”)”, using this property seems to be completely correct.

To verify this issue, I decided to check the directory output in the two different cases.

The output directory for running the app independently:

C:\Users\admin\Desktop\HTTP_Directory\Dynamic .NET TWAIN 5.0 Trial\Samples\Bin\Images\WpfDemoImages\

Start the app from another app:

Process.Start(@"C:\Users\admin\Desktop\HTTP_Directory\Dynamic .NET TWAIN 5.0 Trial\Samples\C# Samples\VS 08\WpfControlsDemo\WpfControlsDemo\bin\Debug\WpfControlsDemo.exe");

Output directory:

C:\Users\admin\Desktop\HTTP_Directory\WPF TEst\WPF TEst\bin\Debug

As you can see, the two result are different. The second output directory is the working directory of the caller application. In this situation, the Property Environment.CurrentDirectory cannot return the expected result.

Is there an alternative? As a matter of fact, Microsoft provides another method. Here is what I found:

String strAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
String imageDirectory = strAssemblyPath.Substring(0, strAssemblyPath.IndexOf("Samples")) + @"Samples\Bin\Images\WpfDemoImages\";

This method returns the location of the loaded executable file. Therefore, we can easily find out the relative path of the resource files. Now, our WPF projects can work perfectly.

Tour in Boracay Island

For the last week, I had been having a great vacation on Boracay Island. Boracay Island is a small island in the Philippines, which is renowned for its white sand beaches. It’s one of the world’s top destinations for relaxation. It is unfortunate that the whole country just suffered from typhoon Haiyan. Some places are still a mess, and the local people have to use electric generators to maintain their lives. Some tourists might worry about whether it is safe in the Philippines. My answer is yes. It is still worth travelling. I would like to show what I witnessed in Boracay Island.

It was a long journey. Heading for Boracay Island, I had to use different means of transportation:

  1. Take flight to Kalibo airport
  2. Take a shuttle bus from the airport to the dock
  3. Take a boat to reach Boracay Island
  4. Take a taxi to the hotel

I was surprised when I saw such blue sky and clear water. It’s so beautiful.


The Hotel I stayed in is called “Fairways & Blue Water”.

villa Read more

Dynamic .NET TWAIN 5.0 Released!

I’m glad to announce Dynamic .NET TWAIN 5.0 is released today. Dynamic .NET TWAIN is a .NET Component for TWAIN Scanning which enables you to acquire images from any TWAIN compliant devices and UVC compatible Webcams, edit the scanned images and then save them to a local disk, web server, database or FTP site.

Here are some highlights of the new features in version 5.0:

  • Added WPF version of Dynamic .NET TWAIN, which makes it easier to integrate document scanning feature into your WPF applications.
  • Added an IfShowCancelDialogWhenBarcodeOrOCR property to display a progress bar while doing barcode or OCR.
  • Added an OnWaitForEnd event to detect the beginning and ending of Barcode/OCR progress.
  • Changed the way trial notification is displayed to make it more friendly
  • Added GIF format support for load and download methods.
  • Improved the Print method so that users are able to print the desired number of pages instead of just all of them.


Release Notes of 5.0 >>
Try Dynamic .NET TWAIN Demo >>
Download 30-day free trial of Dynamic .NET TWAIN 5 >>
How to upgrade to v5.0 >>

Thanks for the continued support of our customers. I hope you enjoy the new version.


Adwords Tips for Beginners

Google Adwords is definitely a powerful tool for business. Everyone can take advantage of advertisements online within their budget. In this tutorial, I would like to share some tips on using Adwords.

Basic steps

Adwords can be simplified to four steps:

  1. Create an account
  2. Find the relevant keywords to your product
  3. Create some advertisements based on the keywords
  4. Adjust and optimize the advertisements

How to create an Adwords account?

When logging in to Adwords for the first time, there is nothing there. Click Create account.

create account

Fill out the form to create an account.


How to find keywords?

Before creating an advertisement, the most significant thing is to find useful keywords. Try to find and refine some relevant keywords for ads display. There is a keyword tool named Keyword Planner located in the menu group Tools and Analysis, which is an excellent phrase sniffer and decision maker.

keyword planner

The Keyword Planner includes four functions as shown in the figure below.


To figure out as many relevant phrases as you can, select the first function to get some ideas. For example, type in google

idea result

There are lots of results returned. Now you can pick which phrase can be used based on monthly searches and competition. If you are good at making phrases, you just need to choose the second function to get search volume for keywords.

So what is the average monthly searches and why it is important?

“The average number of times people have searched for this exact keyword based on the targeting settings that you’ve selected” by Google. The searches volume gives you an idea of how many users you might have.

How to create an Ad?

Once you have picked the relevant keywords, it is the time to create some advertisements. For boosting advertising effectiveness and ad management, it’s best to segment it  based on the different aspects of your product. To create an ad, you have to first create a campaign, and then an ad group.

Create a campaign

When clicking +Campaign, there are three options: Search Network with Display Select, Search Network only, Display Network only. 

Search Network

“A group of search-related websites where your ads can appear. These include Google search sites and search sites that partner with Google to show ads” by Google.

Display Network

“A group of more than a million websites, videos, and apps where your ads can appear. Sites in this network have partnered with Google to show relevant AdWords ads” by Google.

You can choose one of the options based on your business size and target customer. With a limited budget, focusing on the search network may be the good choice.

Create an ad group & an ad

Creating an ad group is similar as creating a campaign.

create adgroup

create ad

How to adjust and optimize advertisements?

So far, we have successfully created an ad. For better advertising effectiveness, you will need to do some adjustment and optimization.


As Google recommended, extensions give customers more reasons to click your ad. The value of extension is to provide additional information about your ad, such as your company location, phone number, site links, product description and so forth. You can create different types of extensions.


Negative Filter

If some of the chosen phrases include ambiguous words, the advertising effectiveness will be influenced. For example, let’s say your product is related to TWAIN (From Wikipedia: an applications programming interface and communications protocol that regulates communication between software and digital imaging devices, such as image scanners and digital cameras), but this word also represents a family name, like “Mark Twain”. In this case, to display your ad to the right customers, you have to add “Mark Twain” to the negative keywords list. This function can be found at the bottom of keywords page.


Location, Schedule & Devices

In settings, there are three important tabs: Locations, Ad schedule and Devices.

Locations are the places triggering the ads. You can check the data periodically to see which country is worth advertisement to.

Ad Schedule is used to control what day and time your ads will be displayed. For example, you do not need to waste money if your potential customers are sleeping.

Devices show the statistics of different platforms, desktop and mobile. According to clicks and impressions, you can adjust your strategies.



For more information about Adwords, you can access the Adwords help center or subscribe the Adwords blog.

How does Android 4.4 KitKat Impress Me

Android 4.4 KitKat has been out for a couple of days now. Google has brought us some excellent few features. And, I can see the smokeless war between Google and Apple heating up. It is no doubt that competition makes for a better product experience. I would like to share some of Android 4.4’s exciting features , and make a comparison to Android’s biggest rival iOS 7.

Google Now vs Siri

How many users have dreamed about using a touch-less control for their phones? Now you just need to say “OK Google” to run Google Now. Without your hand, you can search your contacts, make a phone call, send SMS, check the weather, and so on. In the meantime, iOS Siri still needs to be triggered by holding down the home button. I still remember there was an ad showing how Siri assists people while they are driving. How can we manipulate our phones if we have to focus on the steering wheel?  Finally, Google has really allowed us to free-up our hands.

Hangouts vs iMessage

iMessage is definitely the killer of traditional SMS services, but it is only accessible to Apple users. Now, the new Hangouts app has brought this feature to Android users, and even made it better. Not only SMS and MMS are supported, but also locations and animated GIFs.

CloudPrint vs AirPrint

Android users do not need to be jealous of iOS users any more. Android 4.4 allows users to print web pages, photos and documents to any printer that’s connected to Google CloudPrint. This service is the same as AirPrint. Congratulations to all Android users.

Quickoffice vs iWork

Quickoffice has been redesigned by Google, and is totally free now. It is compatible with Microsoft Office Word, Excel, and PowerPoint. What’s more, you can save your work to Google Drive which provides up to 15G of storage for free. How generous Google is comparing to Apple. As we know, Apple announced iWork for free recently, but it is still only for those who purchased the latest iOS devices.

Nexus 5 vs iPhone 5S

Google has said that Android 4.4 will run on handsets with just 512MB of RAM. This is absolutely a breakthrough, because the current Android market seems to be much like a hardware race. Some big companies always put their focus on flagship devices as a sales strategy, not the software user experience. In contrast to iOS, Apple is still limiting its hardware, including RAM, battery volume, camera resolution and CPU frequency. Apparently, Google wants to change this situation. The new system has been optimized a lot, and can even run on old devices. With such a system, the performance of Nexus 5 is much better than any of the previous Nexus devices. With its low price, the Nexus 5  could be the biggest iPhone 5S challenger to date.

In additional to these features compared above, we can explore more unique features like screen recording, support for IR blasters, immersive experience, smart caller ID and so forth. If you are an Android fan, do not hesitate to get the best Android experience right now.

How to Use Dynamic Web TWAIN with Internet Explorer 11 on Windows 8.1

It’s been a while now since Microsoft released a Windows 8.1 Preview with a Preview of IE 11 too. No doubt many users have already tested it. It is apparent that Microsoft has entirely rebuilt the developer tools and made them much more beautiful and powerful. There are eight distinct tools: DOM Explorer, Console, Debugger, Network, UI Responsiveness, Profiler, Memory, and Emulation. In this article, I will share some of my experiences with the debugger and console tools of IE 11. And I’ll provide a review of a hands-on test on how Dynamic Web TWAIN works with IE 11.

Read more

How to Read Barcode in WPF with VB.NET

We’re proud to reveal that Dynamsoft’s Dynamic .NET TWAIN 5.0 is on its way to release soon. In addition to WinForms support, the new version will include a WPF control. You can use it in your WPF app to capture images from TWAIN scanners and UVC/WIA webcams, to edit and save images to local disks, to a server or a database. Today, I’d like to cover how, using VB.NET, you can use the Dynamic .NET TWAIN 5.0 SDK to implement barcode reading in a WPF application.

The relevant source code can be downloaded here.

Barcode Demo

1.        Create a New WPF Project

First, start Visual Studio .NET, and create a new WPF project. Select Visual Basic as the type and choose WPF Application as the template.

Create WPF Project

2.        Add a Reference

Right-click on the project root, and select Add Reference… from the menu. Click Browse to locate DynamicDotNetTWAIN.dll and add it.

WPF Reference

3.      Add Dynamic .NET TWAIN Component

If there is no Dynamic .NET TWAIN component available, you might need to open the toolbox. To do so, right-click on the panel and select Choose Items… Switch to the tab WPF Components and click Browse… to load DynamicDotNetTWAIN.Wpf.dll

 WPF Component

4.         Add Buttons and Textbox

Next, you’ll want to drag two buttons and one textbox from the toolbox to design a form. The buttons are used to load an image and make the detection of a barcode. And, the textbox is used to display the information decoded from barcode.

WPF Button

5.         Code for Loading Image

Now, what you need to do is to acquire an image using the Windows standard API. Then you’ll need to load it using the Dynamic .NET TWAIN component method. Just a couple of lines of code are needed for loading an image. It’s pretty simple.

       Dim filedlg As OpenFileDialog
        filedlg = New OpenFileDialog()
        filedlg.Multiselect = True
       Dim strFilename As String
        If (filedlg.ShowDialog() = DialogResult.OK) Then
            For Each strFilename In filedlg.FileNames
        End If

6.         Code for Barcode Recognition

To decode a barcode, the path for the barcode library needs to be first be specified. Then, with one additional line of code, you’ll get results.

Set the path of barcode library

        Dim strDllFolder As String
        strDllFolder = Application.ExecutablePath
        Dim pos As Integer
        pos = strDllFolder.LastIndexOf("\Samples\")
        If (pos <> -1) Then
            strDllFolder = strDllFolder.Substring(0, strDllFolder.IndexOf("\", pos)) + "\Bin\BarcodeResources\"
        End If
        Me.DynamicDotNetTwain1.BarcodeDllPath = strDllFolder

Get the results and display them on screen

        Me.TextBox1.Text = ""
        Dim aryResult() As Result
        aryResult = Me.DynamicDotNetTwain1.ReadBarcode(Me.DynamicDotNetTwain1.CurrentImageIndexInBuffer, BarcodeFormat.All)
        Dim strText As StringBuilder
        strText = New StringBuilder()
        If aryResult.Length = 1 Then
            strText.AppendFormat(aryResult.Length & " total barcode" & ("") & " found." & Constants.vbCrLf)
            strText.AppendFormat(aryResult.Length & " total barcode" & ("s") & " found." & Constants.vbCrLf)
        End If
        For i As Integer = 0 To aryResult.Length - 1
            Dim objResult As Result
            objResult = aryResult(i)
            strText.AppendFormat("      Result " & (i + 1) & Constants.vbCrLf)
            strText.AppendFormat("      BarcodeFormat: " & objResult.BarcodeFormat.ToString() & Constants.vbCrLf)
            strText.AppendFormat("      Text read: " & objResult.Text & Constants.vbCrLf)
        Next i
        Me.TextBox1.Text = strText.ToString()

I hope this brief tutorial is helpful to anyone who is looking for a .NET barcode reader SDK in VB.NET.

For further inquiries, please feel free to send me an email at kgao[at]

Dynamic .NET TWAIN 5.0 is scheduled to be released late next month. To stay informed about all our product announcements, blog posts and more, be sure to follow us on Twitter, like us on Facebook or add us on Google+. Also, if you’d like to be amongst the first to try out the new version first, please contact support[at]

Is the Age of Free Operating System Coming?

There was news earlier this week that Apple will be providing its latest operating system, Mavericks, for free. It is apparently good news to just about all Mac users. There are also sure to be some people that may wonder whether this is a strategy against Microsoft. Just a couple of days ago, Microsoft announced that it would not charge consumers who upgrade their OS from Windows 8 to Windows 8.1.

For most consumers, there is nothing more important than an acceptable price point. Who doesn’t want to have a free meal? Apple began to drop OS prices starting with version 10.6 of Snow Leopard, which at the time was around $29 for the upgrade. It keeps getting lower and lower with each new release. Version 10.8 is currently $19.99. It’s well known that the operating system and Office suite are very significant products for Microsoft. They have been a primary source of Microsoft’s revenue to date. However, the OS and Office business is shrinking. There’s considerable agreement that what Apple is doing is having a huge impact on these Microsoft products.

Besides the free OS, Apple also announced that iLife and iWork are both free for consumers who purchased the latest Mac and iOS devices. So how will Apple then make a profit? Apple has established an excellent ecosystem with the Appstore for developers and consumers. This business model consists of advertisements, in-app purchases and cheap apps. With billions of consumers and probably hundreds of thousands of developers in hand, it is pretty easy for Apple to make money.

Also, the effective marketing of the booming mobile market is having a big influence on the PC market. Apple, as the pioneer of the smartphone, is trying to fuse their mobile OS and desktop OS with consistent experiences. To this end, it seems Apple decided to make the desktop OS free, just like the mobile OS. It is also a good approach to try and attract more consumers to the Mac platform, especially when comparing it to Windows’ price.

So, Apple is making a profit with hardware and services and this is Apple’s unique business model. Let’s think about what Google is doing. Google’s Nexus series may be the cheapest mobile devices in the world and its Android operating system is even open-source. The OS is provided to transplant to any hardware, including mobile devices, TVs, vehicles, fridges, and so forth. So, even Google is about the service and not making money on the OS. For example, most apps in the Apple or Google platform are free now. They instead depend on added value in apps or ads for income. Another typical example can be seen in telecommunications. Here consumers sign up for a service contract for a period of time to get a cellphone for free. Instead of paying for hardware they pay for service – they pay for their call and data usage plans each month. This is an established business model in telecommunications that earns them more money.

In the end, the competition between these giant companies benefits consumers. It spurs new technology and changing business model that address consumer wants. Perhaps it has even ushered in the age of the free operating system.

Dynamsoft Is 10 Years Old!

Founded in September 2003, Dynamsoft is now 10 years old. Happy birthday! Throughout the first ten years, Dynamsoft has grown a lot with hard work by all employees. And, of course, we couldn’t have accomplished our growth without continued support from all customers. We are grateful to our employees and our customers for their dedication and help in making Dynamsoft a success.

When you reach a decade-long milestone like Dynamsoft has, it’s important to reflect upon the journey that got you here to maximize successes for the journey ahead. Here’s a quick look back.

Dynamsoft Product History

  1. Dynamsoft released its first image capture SDK product, Dynamic TWAIN, on Aug. 8, 2003. This was just prior to the official company establishment in Sept. 2003.
  2. On Aug. 20, 2003, Dynamic Web TWAIN 1.0 was released. This web-based scanning SDK has since expanded to support all mainstream browsers on Windows and Mac OS X, including browsers that have come and gone.
  3. On Nov. 15, 2003, Dynamsoft introduced SourceAnywhere for VSS (original name SourceAnywhere), a remote access add-on tool for Microsoft Visual SourceSafe (VSS). In the ‘good old days‘ of SourceSafe, many customers were thrilled to find SourceAnywhere for VSS which facilitated Internet access to local VSS databases from anywhere.
  4. Dynamsoft opened its first official office in Vancouver, Canada, in Sept. 2004. Today, the company has two offices. In addition to the Vancouver office, there is another in Asia. This expansion enabled Dynamsoft to better serve global customers.
  5. Dynamsoft earned its very first customer – LOCKHEED MARTIN – in Dec, 2004. Today, thousands of customers including HP, IBM, Intel, and Siemens use Dynamsoft source control solutions/services and imaging SDKs. See our partial customer list
  6. On Jul. 18, 2005, Dynamsoft released Issue Tracking Anywhere, a web-based issue and bug tracking solution.
  7. On Jan. 5, 2006, SourceAnywhere Standalone (original named SourceHero) was released to the public. This source control solution was designed as a replacement for SourceSafe. To this day many customers like it because of its ease of use, speedy performance, and stability.
  8. On Jun. 4, 2007, Dynamsoft released SourceAnywhere Hosted, which is the SaaS version of SourceAnywhere Standalone.
  9. On Oct.17, 2007, Dynamsoft earned Gold Certified Partner Status within the Microsoft Partner Program.
  10. n Dec. 18, 2008, SCM Anywhere was released. This is a simple software configuration management solution which combines source control and issue tracking features. (The product was pulled off the shelves in June, 2012.)
  11. Dynamic .NET TWAIN was released on Jan. 20, 2010.
  12. In Mar. 2011, Dynamsoft became an associate member of the TWAIN Working Group, which defines the TWAIN standard.
  13. On Dec. 10, 2011, Dynamsoft started providing hosting services for Microsoft Team Foundation Server.
  14. On Nov. 12, 2012, ImageCapture Suite was made available. Based on Dynamic Web TWAIN, it added support for image capturing from webcams.
  15. On Jan. 08, 2013, Dynamsoft released barcode reader and OCR SDKs, available in both ImageCapture Suite (web based) and Dynamic .NET TWAIN (.net version).

Dynamsoft continues to aim to be a dynamic center for software developers. To this end, our product lines continue a focus on source control and TWAIN/imaging SDKs. We’ve made many product updates in 2013 alone to continue to address our customer requirements for advanced source control and image capture application solutions.

We look forward to another 10 golden years with our employees and working closely with our customers. Again, we are sincerely grateful for your support during our first 10 years of growth.

SourceAnywhere 64-bit Server is available!

I’m pleased to announce that SourceAnywhere 64-bit Server is released on September 25th, 2013. This is a SQL server-based version control software designed as a VSS replacement.

As you may already know, a 32-bit application may not work very efficiently sometimes, as its available memory and CPU are limited. With the new release of SourceAnywhere 64-bit Server, the capacity and performance of SourceAnywhere server are now greatly improved!

If you are running a medium-sized or large team, it is highly recommended that you upgrade to the 64-bit version on your 64-bit Windows server for the best performance.

Check out the Release Notes >>

Download the 30-day free trial >>

How to upgrade to the latest version? >>

If you have any questions or comments regarding the new release, please feel free to let me know (